Example #1
0
    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);
    }
Example #2
0
        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));
        }
Example #3
0
        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);
        }
Example #4
0
        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());
        }
Example #5
0
 public static Rol ToRol(RolRequest rol)
 {
     return(new Rol {
         Id = rol.Id, Nombre = rol.Nombre
     });
 }
Example #6
0
 public RolResponse delRol(RolRequest request)
 {
     throw new NotImplementedException();
 }