コード例 #1
0
ファイル: TaskService.cs プロジェクト: StringerKent/NUCode
        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();
            }
        }
コード例 #2
0
ファイル: TaskService.cs プロジェクト: StringerKent/NUCode
        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;
                }
            }
        }
コード例 #3
0
ファイル: TaskService.cs プロジェクト: StringerKent/NUCode
        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();
            }
        }
コード例 #4
0
ファイル: TaskService.cs プロジェクト: StringerKent/NUCode
        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();
            }
        }