public RolResponse guardaRol(RolRequest request) { var Contexto = new UMSernaSotomayorEntities(); RolResponse response; var rol = Contexto.Rols.FirstOrDefault(r => r.Id.Equals(request.Id)); if (rol == null) { rol = Contexto.Rols.Add(Ensamblador.ToRol(request)); } else { rol.Nombre = request.Nombre; } try { Contexto.SaveChanges(); response = new RolResponse { Id = rol.Id, Nombre = rol.Nombre }; } catch (Exception ex) { response = new RolResponse { Id = rol.Id, Nombre = rol.Nombre }; response.Error.ErrNum = ex.HResult; response.Error.ErrMensaje = ex.Message; } return(response); }
public Response <Rol> Add(RolRequest request) { Rol entity = request.ToEntity(); base.Add(entity); if (entity.Id == 0) { return(new RolResponse("Rol no registrado")); } return(new RolResponse("Rol registrado", entity)); }
private static UserRequest getUserRequest() { var rol = new RolRequest() { idGuid = Guid.NewGuid() }; var user = new UserRequest { firstName = "Dante", Id = "DRCD", userRol = rol, mail = "xx", password = "******", secondName = "Castillo" }; return(user); }
public void isValidPost_InvalidData_ReturnFalse(string _id, string _firstName, string _secondName, string _password, string _mail, RolRequest _userRolId) { var request = new UserRequest { Id = _id, firstName = _firstName, secondName = _secondName, mail = _mail, password = _password, userRol = _userRolId }; Assert.IsFalse(request.isValidPost()); }
public static Rol ToRol(RolRequest rol) { return(new Rol { Id = rol.Id, Nombre = rol.Nombre }); }
public RolResponse delRol(RolRequest request) { throw new NotImplementedException(); }