public void Save(UserViewModel user)
        {
            var entity = ToUserEntity(user);

            if (user.UserId == 0)
            {
                _userRepository.Insert(entity);
            }
            else
            {
                _userRepository.Update(entity);
            }
        }
        public ParentTaskViewModel Save(ParentTaskViewModel model)
        {
            var entity = _parentTaskRepository.GetById(model.ParentTaskId);

            if (entity == null)
            {
                entity = ToEntity(model);
                _parentTaskRepository.Insert(entity);
                model.ParentTaskId = entity.ParentTaskId;
            }
            else
            {
                entity.ParentTaskTitle = model.ParentTaskName;
                _parentTaskRepository.Update(entity);
            }

            return(model);
        }
示例#3
0
        public void Save(ProjectViewModel model)
        {
            var entity = _projectRepository.GetById(model.ProjectId);

            if (entity != null)
            {
                entity.Title     = model.ProjectName;
                entity.StartDate = model.StartDate;
                entity.EndDate   = model.EndDate;
                entity.Priority  = model.Priority;
                _projectRepository.Update(entity);
            }
            else
            {
                entity = ToProjectEntity(model);
                _projectRepository.Insert(entity);
            }

            model.ProjectId = entity.ProjectId;
            UpdateUser(model);
        }
示例#4
0
        public void Save(TaskViewModel model)
        {
            ParentTaskViewModel parentTaskViewModel;

            // Parent task
            if (string.IsNullOrEmpty(model.ParentTaskName))
            {
                parentTaskViewModel = SaveParentTask(model);
            }
            else
            {
                var entity = _taskRepository.GetById(model.TaskId);
                if (entity == null)
                {
                    entity = ToEntity(model);
                    _taskRepository.Insert(entity);
                }
                else
                {
                    entity.ParentTaskId = model.ParentTaskId;
                    entity.ProjectId    = model.ProjectId;
                    entity.Title        = model.TaskName;
                    entity.StartDate    = model.StartDate;
                    entity.EndDate      = model.EndDate;
                    entity.Priority     = model.Priority;
                    _taskRepository.Update(entity);
                }

                var userEntity = _userRepository.GetById(model.ManagerId);
                if (userEntity != null)
                {
                    userEntity.TaskId = entity.TaskId;
                    _userRepository.Update(userEntity);
                }
            }
        }