Пример #1
0
        public void CreateOrUpdate(ProjectBindingModel model)
        {
            var element = _projectStorage.GetElement(new ProjectBindingModel
            {
                Name     = model.Name,
                Clientid = model.Clientid
            });;

            if (element != null && element.Id != model.Id)
            {
                throw new Exception("Уже есть такой проект");
            }
            if (model.Id.HasValue)
            {
                _projectStorage.Update(model);
            }
            else
            {
                _projectStorage.Insert(model);
            }
        }
Пример #2
0
        /// <summary>
        /// Saves the specified project aggregate root.
        /// </summary>
        /// <param name="root">The project aggregate root.</param>
        public override void Save(Project root)
        {
            var project = new DB.Models.Project.Project
            {
                Id                    = root.Id.Id,
                Mandatory             = root.Mandatory,
                Name                  = root.Name,
                Description           = root.Description,
                ProjectOrderer        = root.ProjectOrderer,
                RecievingOrganization = root.RecievingOrganization,
                StartDate             = root.StartDate,
                EndDate               = root.EndDate,
                DepartmentId          = root.Department.Id,
                PpsClassificationId   = root.Classification.Id,
                IsDeleted             = root.IsDeleted,
                TeamMembers           = root.TeamMembers == null
                            ? null
                            : root.TeamMembers.Select(x => new DB.Models.Project.ProjectRoleRelation
                {
                    UserId        = x.UserId.Id,
                    ProjectRoleId = x.RoleId,
                    ProjectId     = root.Id.Id,
                    EndDate       = x.EndDate,
                    StartDate     = x.StartDate,
                    FTE           = x.FTE
                }),
                ManagerId = root.Manager.Id,
                OwnerId   = root.Owner.Id
            };

            if (root.IsNew)
            {
                _projectStorage.Add(project);
            }
            else
            {
                _projectStorage.Update(project);
            }
        }