예제 #1
0
 public LibraryObject Update(SystemRol systemRol)
 {
     try
     {
         return(doSystemRol.Update(systemRol));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public HttpResponseMessage Put([FromBody] SystemRol systemRol)
 {
     try
     {
         DbLibrary    dbLibrary   = new DbLibrary();
         BO_SystemRol boSystemRol = new BO_SystemRol(dbLibrary);
         DataMessage  dataMessage = new DataMessage(boSystemRol.Update(systemRol));
         return(Request.CreateResponse(HttpStatusCode.OK, dataMessage));
     }
     catch (Exception e)
     {
         ErrorMessage mensaje = new ErrorMessage("2.1", "Excepción en la actualización del rol: " + e.GetBaseException().Message, e.ToString());
         return(Request.CreateResponse(HttpStatusCode.BadRequest, mensaje));
     }
 }
예제 #3
0
        /// <summary>
        /// Actualiza el registro del rol indicado
        /// </summary>
        /// <param name="systemRol"></param>
        /// <returns></returns>
        public Operations Update(SystemRol systemRol)
        {
            try
            {
                Operations operations = new Operations();

                try
                {
                    SystemRol rol;
                    rol      = dbLibrary.tc_SystemRol.Where(a => a.RoleId == systemRol.RoleId).FirstOrDefault();
                    rol.Name = systemRol.Name;
                    dbLibrary.SaveChanges();
                    operations.Result  = "OK";
                    operations.Message = "Rol actualizado";
                }
                catch (DbEntityValidationException e)
                {
                    regOperacion = new StringBuilder("No se logro actualizar el rol");
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        regOperacion.AppendFormat("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                  eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            regOperacion.AppendFormat("- Property: \"{0}\", Error: \"{1}\"",
                                                      ve.PropertyName, ve.ErrorMessage);
                        }
                    }

                    operations.Result  = "Error";
                    operations.Message = regOperacion.ToString();
                }

                return(operations);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Agrega un nuevo registro a la entidad de roles
        /// </summary>
        /// <param name="systemRol"></param>
        /// <returns></returns>
        public Operations Create(SystemRol systemRol)
        {
            try
            {
                Operations operations = new Operations();

                try
                {
                    dbLibrary.tc_SystemRol.Add(systemRol);
                    dbLibrary.SaveChanges();
                    operations.Result  = "OK";
                    operations.Message = "Registro creado";
                }
                catch (DbEntityValidationException e)
                {
                    regOperacion = new StringBuilder("No se logro crear el registro:-");
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        regOperacion.AppendFormat("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                  eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            regOperacion.AppendFormat("- Property: \"{0}\", Error: \"{1}\"",
                                                      ve.PropertyName, ve.ErrorMessage);
                        }
                    }

                    operations.Result  = "Error";
                    operations.Message = regOperacion.ToString();
                }

                return(operations);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }