public void Handle(UpdateProjectTypeCommand command) { var productType = _projectTypeRepository.Load(command.ProjductTypeId); Guard.IsNotNull(productType, "productType"); if (!string.IsNullOrEmpty(command.TypeName)) { productType.TypeName = command.TypeName; } if (command.IsShow != null) { productType.IsShow = bool.Parse(command.IsShow.ToString()); } _projectTypeRepository.SaveOrUpdate(productType); }
public void Handle(CreateProjectCommand command) { var user = _userRepository.Load(command.UserId); Guard.IsNotNull(user, "user"); var projectType = _projectTypeRepository.Load(command.ProductTypeId); Guard.IsNotNull(projectType, "projectType"); var project = new Project { ProjectName = command.ProjectName, Content = HttpUtility.HtmlEncode(command.Content), CreateDate = DateTime.Now, IsShow = command.IsShow, LastDateTime = DateTime.Now, ProjectImg = command.ProjectImg, StandardProjectImg = command.StandardProjectImg, SmallProjectImg = command.SmallProjectImg, User = user, WebSite = command.WebSite, ProjectType = projectType, Sort = GetTypeMaxSort() }; if (string.IsNullOrEmpty(command.Introduction)) { if (command.Content != null) { project.Introduction = Utils.CutStringBySuffix(Utils.RemoveHtml(command.Content), 0, 300, "..."); } } else { project.Introduction = HttpUtility.HtmlEncode(command.Introduction); } _projectRepository.Save(project); }