Пример #1
0
        public IList <ValidationError> Save(ProjectModel model)
        {
            IList <ValidationError> result;

            using (IGenericTransaction transaction = _unitOfWork.CreateTransaction())
            {
                result = Validate(model);

                if (result.Count > 0)
                {
                    transaction.Commit();

                    return(result);
                }

                IProject project = model.Id.HasValue ? _projectFactory.Get(model.Id.Value) : _projectFactory.New();

                project.Code          = model.Code.Trim();
                project.YouTrackUrl   = model.YouTrackUrl.Trim();
                project.YouTrackQuery = model.YouTrackQuery.Trim();

                try
                {
                    project.Save();
                    model.Id = project.Id;

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }

            return(result);
        }