public ActionResult Add(RoleAddViewModel viewModel) { if (ModelState.IsValid) { Role role = new Role { EntityInfo = EntityInfo.Empty(Dom.EntityType.Role.Id), Name = viewModel.Name, Description = viewModel.Description }; EntityContext.AddEntityProgress(role.EntityInfo, new EntityProgress { OrganizationId = Dom.Common.OrganizationId, EntityStateAfterId = Dom.EntityType.Role.State.Created }); EntityContext.AddEntityProgress(role.EntityInfo, new EntityProgress { OrganizationId = Dom.Common.OrganizationId, EntityStateBeforeId = Dom.EntityType.Role.State.Created, EntityStateAfterId = Dom.EntityType.Role.State.Active }); EntityContext.AddEntityOrganization(role.EntityInfo, Dom.Common.OrganizationId, Dom.EntityType.Role.State.Active); _roleRepository.AddOrUpdate(role); _roleRepository.UnitOfWork.SaveChanges(); return(RedirectToAction(Mvc.Controller.Role.List, Mvc.Controller.Role.Name)); } return(View(Mvc.View.Role.Add, viewModel)); }
// add role and return Id public int AddOrUpdateRole(Role r) { using (TransactionScope tran = new TransactionScope()) { Roles.AddOrUpdate(r); // Complete(); tran.Complete(); return(r.Id); } }
public void Handle(AddUpdateRoleCommand command) { _roleRepository.AddOrUpdate(command.Role); _roleRepository.UnitOfWork.SaveChanges(); }