Пример #1
0
        public JsonResult UpdateTask(string _todoTitle, string _todoDetail, string _todoEndDate, int _todoId, List <int> _todoUsers, List <int> _todoTasks)
        {
            try
            {
                using (var context = new ProjectManagementEntities())
                {
                    var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id;
                    _todoUsers.Add(_personId);
                    _todoUsers = _todoUsers.Distinct().ToList();
                    var projectId  = context.Task.FirstOrDefault(x => x.Id == _todoId).ProjectId;
                    var DetailTask = new Task()
                    {
                        Title     = _todoTitle,
                        Detail    = _todoDetail,
                        EndDate   = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null),
                        Id        = _todoId,
                        Status    = 1,
                        ProjectId = projectId
                    };
                    var result = TaskDB.GetInstance().UpdateTask(DetailTask, _todoUsers);

                    return(Json(result != null));
                }
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }
Пример #2
0
        public JsonResult UpdateQuickTask(string _todoName, string _todoEndDate, int _todoId, int _projectId, List <int> _todoUsers)
        {
            try
            {
                var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id;
                _todoUsers.Add(_personId);
                _todoUsers = _todoUsers.Distinct().ToList();
                var QuickTask = new Task()
                {
                    Title     = _todoName,
                    Detail    = "",
                    EndDate   = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null),
                    Id        = _todoId,
                    Status    = 1,
                    ProjectId = _projectId
                };
                var result = TaskDB.GetInstance().UpdateTask(QuickTask, _todoUsers);

                return(Json(result != null));
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }
Пример #3
0
 public Task SaveTask(Task _Task)
 {
     try
     {
         using (var context = new ProjectManagementEntities())
         {
             context.Task.Add(_Task);
             int numberOfInserted = context.SaveChanges();
             return(numberOfInserted > 0 ? _Task : null);
         }
     }
     catch (System.Exception exc)
     {
         throw exc;
     }
 }
Пример #4
0
        public Task UpdateTask(Task _s, List <int> _workerIds)
        {
            try
            {
                var numberOfUpdated = 0;
                using (var context = new ProjectManagementEntities())
                {
                    var Task = context.Task.FirstOrDefault(x => x.Id == _s.Id);

                    if (Task != null)
                    {
                        Task.Title      = _s.Title;
                        Task.Detail     = _s.Detail;
                        Task.EndDate    = _s.EndDate;
                        numberOfUpdated = context.SaveChanges();
                        var TaskPerson = context.TaskUser.Where(x => x.TaskId == _s.Id).ToList();

                        if (TaskPerson.Count() > 0)
                        {
                            foreach (var TaskPersonItem in TaskPerson)
                            {
                                var TaskPersonDetail = context.TaskUser.Where(x => x.PersonId == TaskPersonItem.PersonId).ToList();
                                context.TaskUser.RemoveRange(TaskPersonDetail);
                                context.SaveChanges();
                            }
                        }
                        foreach (var item in _workerIds)
                        {
                            var newTaskPerson = new TaskUser()
                            {
                                PersonId = item,
                                TaskId   = _s.Id
                            };

                            context.TaskUser.Add(newTaskPerson);
                            context.SaveChanges();
                        }
                        return(numberOfUpdated > 0 ? _s : null);
                    }
                    return(null);
                }
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }
Пример #5
0
        public JsonResult SaveCategoryStep(string _todoName, string _todoEndDate, int _projectId, int _catId, List <int> _todoUsers)
        {
            try
            {
                var _personId = JsonConvert.DeserializeObject <Person>(HttpContext.Session.GetString("ActivePerson")).Id;
                if (_projectId == 0)
                {
                    _projectId = JsonConvert.DeserializeObject <Project>(HttpContext.Session.GetString("SelectedProject")).Id;
                }
                _todoUsers.Add(_personId);

                _todoUsers = _todoUsers.Distinct().ToList();

                var todo = new Task()
                {
                    Detail     = "",
                    Title      = _todoName,
                    ProjectId  = _projectId,
                    EndDate    = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null),
                    Status     = 1,
                    CategoryId = _catId
                };

                var result = TaskDB.GetInstance().SaveTask(todo);

                foreach (var item in _todoUsers)
                {
                    var todouser = new TaskUser()
                    {
                        TaskId   = result.Id,
                        PersonId = item
                    };

                    TaskUserDB.GetInstance().SaveTaskUser(todouser);
                }

                return(Json(result != null));
            }
            catch (System.Exception exc)
            {
                throw exc;
            }
        }