Skip to content
This repository was archived by the owner on Oct 3, 2022. It is now read-only.

Commit 1ef5443

Browse files
committed
ticking off subtasks and aborting them
1 parent 9a96ca7 commit 1ef5443

22 files changed

+489
-37
lines changed
0 Bytes
Binary file not shown.

.vs/TakeMyTime.NETCore/v16/.suo

512 Bytes
Binary file not shown.

TakeMyTime.BLL/Logic/SubtaskLogic.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Common.Enums;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -41,13 +42,25 @@ public void Update(int id, Subtask.IUpdateParam param)
4142
unitOfWork.Complete();
4243
}
4344

44-
public void AddEntry(int subtask_id, Entry.ICreateParam param)
45+
public Entry AddEntry(int subtask_id, Entry.ICreateParam param, bool finishesSubtask = false)
4546
{
4647
var entry = Entry.Create(param);
4748
entry.Subtask_Id = subtask_id;
4849
var subtask = unitOfWork.Subtasks.GetSubtaskFullyLoaded(subtask_id);
49-
subtask.Entries.Add(entry);
50+
if (subtask != null)
51+
{
52+
subtask.Entries.Add(entry);
53+
if (finishesSubtask)
54+
{
55+
subtask.SetStatus(EnumDefinition.SubtaskStatus.Done);
56+
}
57+
}
58+
else
59+
{
60+
unitOfWork.Entries.Add(entry);
61+
}
5062
unitOfWork.Complete();
63+
return entry;
5164
}
5265

5366
public void Delete(int subtask_id)
@@ -57,6 +70,20 @@ public void Delete(int subtask_id)
5770
unitOfWork.Complete();
5871
}
5972

73+
public void SetSubtaskTickedOff(int subtask_id)
74+
{
75+
var subtask = unitOfWork.Subtasks.Get(subtask_id);
76+
subtask.SetStatus(EnumDefinition.SubtaskStatus.Done);
77+
unitOfWork.Complete();
78+
}
79+
80+
public void SetSubtaskAborted(int subtask_id)
81+
{
82+
var subtask = unitOfWork.Subtasks.Get(subtask_id);
83+
subtask.SetStatus(EnumDefinition.SubtaskStatus.Aborted);
84+
unitOfWork.Complete();
85+
}
86+
6087
public void Dispose()
6188
{
6289
unitOfWork.Dispose();

TakeMyTime.DAL/Migrations/20200318222324_assignment_id.Designer.cs

Lines changed: 245 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
namespace TakeMyTime.DAL.Migrations
4+
{
5+
public partial class assignment_id : Migration
6+
{
7+
protected override void Up(MigrationBuilder migrationBuilder)
8+
{
9+
migrationBuilder.AddColumn<int>(
10+
name: "Assignment_Id",
11+
table: "Entries",
12+
nullable: true);
13+
}
14+
15+
protected override void Down(MigrationBuilder migrationBuilder)
16+
{
17+
migrationBuilder.DropColumn(
18+
name: "Assignment_Id",
19+
table: "Entries");
20+
}
21+
}
22+
}

TakeMyTime.DAL/Migrations/TakeMyTimeDbContextModelSnapshot.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1616
modelBuilder
1717
.HasAnnotation("ProductVersion", "3.1.0");
1818

19-
modelBuilder.Entity("TakeMyTime.DOM.Models.Assignment", b =>
19+
modelBuilder.Entity("TakeMyTime.Models.Models.Assignment", b =>
2020
{
2121
b.Property<int>("Id")
2222
.ValueGeneratedOnAdd()
@@ -59,12 +59,15 @@ protected override void BuildModel(ModelBuilder modelBuilder)
5959
b.ToTable("Assignments");
6060
});
6161

62-
modelBuilder.Entity("TakeMyTime.DOM.Models.Entry", b =>
62+
modelBuilder.Entity("TakeMyTime.Models.Models.Entry", b =>
6363
{
6464
b.Property<int>("Id")
6565
.ValueGeneratedOnAdd()
6666
.HasColumnType("INTEGER");
6767

68+
b.Property<int?>("Assignment_Id")
69+
.HasColumnType("INTEGER");
70+
6871
b.Property<string>("Comment")
6972
.HasColumnType("TEXT");
7073

@@ -107,7 +110,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
107110
b.ToTable("Entries");
108111
});
109112

110-
modelBuilder.Entity("TakeMyTime.DOM.Models.Project", b =>
113+
modelBuilder.Entity("TakeMyTime.Models.Models.Project", b =>
111114
{
112115
b.Property<int>("Id")
113116
.ValueGeneratedOnAdd()
@@ -201,16 +204,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
201204
b.ToTable("Subtasks");
202205
});
203206

204-
modelBuilder.Entity("TakeMyTime.DOM.Models.Assignment", b =>
207+
modelBuilder.Entity("TakeMyTime.Models.Models.Assignment", b =>
205208
{
206-
b.HasOne("TakeMyTime.DOM.Models.Project", "Project")
209+
b.HasOne("TakeMyTime.Models.Models.Project", "Project")
207210
.WithMany("Assignments")
208211
.HasForeignKey("Project_Id");
209212
});
210213

211-
modelBuilder.Entity("TakeMyTime.DOM.Models.Entry", b =>
214+
modelBuilder.Entity("TakeMyTime.Models.Models.Entry", b =>
212215
{
213-
b.HasOne("TakeMyTime.DOM.Models.Project", "Project")
216+
b.HasOne("TakeMyTime.Models.Models.Project", "Project")
214217
.WithMany("Entries")
215218
.HasForeignKey("Project_Id");
216219

@@ -219,7 +222,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
219222
.HasForeignKey("SubtaskId");
220223
});
221224

222-
modelBuilder.Entity("TakeMyTime.DOM.Models.Project", b =>
225+
modelBuilder.Entity("TakeMyTime.Models.Models.Project", b =>
223226
{
224227
b.HasOne("TakeMyTime.Models.Models.ProjectType", "ProjectType")
225228
.WithMany("Projects")
@@ -230,7 +233,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
230233

231234
modelBuilder.Entity("TakeMyTime.Models.Models.Subtask", b =>
232235
{
233-
b.HasOne("TakeMyTime.DOM.Models.Assignment", "Assignment")
236+
b.HasOne("TakeMyTime.Models.Models.Assignment", "Assignment")
234237
.WithMany("Subtasks")
235238
.HasForeignKey("Assignment_Id");
236239
});

0 commit comments

Comments
 (0)