Example #1
0
        public bool CreateTask(WorkTaskEditVM model)
        {
            try
            {
                var entity = new WorkTask();
                model.ToEntity(entity);

                entity.CourtId       = userContext.CourtId;
                entity.DateCreated   = DateTime.Now;
                entity.UserCreatedId = userContext.UserId;
                entity.TaskStateId   = WorkTaskConstants.States.New;
                var taskType = repo.GetById <TaskType>(model.TaskTypeId);
                if (taskType.SelfTask == true || entity.UserId == userContext.UserId)
                {
                    entity.UserId       = userContext.UserId;
                    entity.DateAccepted = DateTime.Now;
                    entity.TaskStateId  = WorkTaskConstants.States.Accepted;
                }
                CreateTaskSourceDescription(entity);
                repo.Add(entity);
                repo.SaveChanges();
                model.Id = entity.Id;
                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(false);
            }
        }
Example #2
0
 public bool UpdateTask(WorkTaskEditVM model)
 {
     try
     {
         var entity = repo.GetById <WorkTask>(model.Id);
         model.ToEntity(entity);
         repo.Update(entity);
         repo.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         return(false);
     }
 }