Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
 // add role and return Id
 public int AddOrUpdateRole(Role r)
 {
     using (TransactionScope tran = new TransactionScope()) {
         Roles.AddOrUpdate(r);
         //    Complete();
         tran.Complete();
         return(r.Id);
     }
 }
Ejemplo n.º 3
0
 public void Handle(AddUpdateRoleCommand command)
 {
     _roleRepository.AddOrUpdate(command.Role);
     _roleRepository.UnitOfWork.SaveChanges();
 }