Exemplo n.º 1
0
 public ActionResult Edit(StatusModel pStatusModel)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(Json(JsonError.AUTHENTICATED_DENIED));
     }
     if (!Request.IsAjaxRequest())
     {
         return(Json(JsonError.AJAX_DENIED));
     }
     try
     {
         JsonResponse vJsonResponse = new JsonResponse();
         if (ModelState.IsValid)
         {
             TitiushkoStatus vTitiushkoStatus = db.TitiushkoStatus.Find(pStatusModel.Id);
             if (vTitiushkoStatus == null)
             {
                 return(Error404());
             }
             vTitiushkoStatus.Name         = pStatusModel.Name;
             vTitiushkoStatus.Description  = pStatusModel.Description;
             vTitiushkoStatus.DateModified = DateTime.Now;
             vTitiushkoStatus.UserModified = User.Identity.Name;
             db.SaveChanges();
             vJsonResponse.Message.Add(string.Format(Resources.Resource.TextEditSuccessFor, Resources.Resource.ModuleStatusName));
         }
         else
         {
             vJsonResponse.SetErrorMessage(ModelState, string.Format(Resources.Resource.TextEditErrorFor, Resources.Resource.ModuleStatusName));
         }
         return(Json(vJsonResponse));
     }
     catch (DbEntityValidationException vEntityException)
     {
         Logging.Logger.Error(vEntityException);
         return(Json(JsonError.EXCEPCION(vEntityException)));
     }
     catch (Exception vException)
     {
         Logging.Logger.Error(vException);
         return(Json(JsonError.EXCEPCION(vException)));
     }
 }
Exemplo n.º 2
0
        public static StatusModel FindAndConvertToCustomModel(this DbSet <TitiushkoStatus> pDbSetTitiushkoStatus, int?pId)
        {
            if (pId == null)
            {
                return(null);
            }
            TitiushkoStatus vTitiushkoStatus = pDbSetTitiushkoStatus.Find(pId);

            if (vTitiushkoStatus == null)
            {
                return(null);
            }
            return(new StatusModel()
            {
                Id = vTitiushkoStatus.Id,
                Name = vTitiushkoStatus.Name,
                Description = vTitiushkoStatus.Description
            });
        }
Exemplo n.º 3
0
 public JsonResult DeleteConfirmed(int?id)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(Json(JsonError.AUTHENTICATED_DENIED));
     }
     if (!Request.IsAjaxRequest())
     {
         return(Json(JsonError.AJAX_DENIED));
     }
     try
     {
         if (id == null)
         {
             return(Json(JsonError.ERROR_400));
         }
         TitiushkoStatus vTitiushkoStatus = db.TitiushkoStatus.Find(id);
         if (vTitiushkoStatus == null)
         {
             return(Json(JsonError.ERROR_404));
         }
         db.TitiushkoStatus.Remove(vTitiushkoStatus);
         db.SaveChanges();
         return(Json(new JsonResponse()
         {
             Message = new HashSet <string>()
             {
                 string.Format(Resources.Resource.TextDeleteSuccessFor, Resources.Resource.ModuleStatusName)
             }
         }));
     }
     catch (DbEntityValidationException vEntityException)
     {
         Logging.Logger.Error(vEntityException);
         return(Json(JsonError.EXCEPCION(vEntityException)));
     }
     catch (Exception vException)
     {
         Logging.Logger.Error(vException);
         return(Json(JsonError.EXCEPCION(vException)));
     }
 }