public void EditTaskById(int id, TaskModel model) { using (var db = new TaskModelEntities()) { TaskModelDAL.Task taskToEdit = new TaskModelDAL.Task() { Name = model.Name, DateCompleted = model.DateCompleted, DateStart = model.DateStart, Description = model.Description, DueDate = model.DueDate, EstimatedDuration = model.EstimateDuration.ToString(), id = holderID, IsCompleted = model.IsCompleted, Tag1 = model.Tags[0], Tag2 = model.Tags[1], Tag3 = model.Tags[2] }; DeleteTaskById(model.TaskId); db.Tasks.Add(taskToEdit); db.SaveChanges(); } }
public void ArchiveTask(TaskModel model) { using (var db = new TaskModelEntities()) { TaskModelDAL.Task taskToEdit = new TaskModelDAL.Task() { Name = model.Name, DateCompleted = DateTime.Now, DateStart = model.DateStart, Description = model.Description, DueDate = model.DueDate, EstimatedDuration = model.EstimateDuration.ToString(), id = holderID, IsCompleted = !model.IsCompleted, TaskValue = model.TaskValue, Tag1 = model.Tags[0], Tag2 = model.Tags[1], Tag3 = model.Tags[2], UserId = model.UserId }; DeleteTaskById(model.TaskId); db.Tasks.Add(taskToEdit); try { db.SaveChanges(); } catch (Exception e) { string s = e.Message; } } }
public void AddTask(TaskModel model) { using (var db = new TaskModelEntities()) { var query = db.Tasks.Select(x => x); model.TaskId = query.Count(); TaskModelDAL.Task taskToAdd = new TaskModelDAL.Task() { Name = model.Name, DateCompleted = model.DateCompleted, DateStart = DateTime.Now, Description = model.Description, DueDate = model.DueDate, EstimatedDuration = model.EstimateDuration.ToString(), id = model.TaskId, IsCompleted = false, Tag1 = model.Tags[0], Tag2 = "", Tag3 = "", TaskValue = model.TaskValue, UserId = model.UserId }; db.Tasks.Add(taskToAdd); db.SaveChanges(); } }
public void DeleteTaskById(int id) { using (var db = new TaskModelEntities()) { var task = db.Tasks.Where(x => x.id == holderID).First(); db.Tasks.Remove(task); db.SaveChanges(); } }