Ejemplo n.º 1
0
        public ActionResult PermissionUpdatePartial(
            [ModelBinder(typeof(DevExpressEditorsBinder))] SecurityPermissionModel item, Guid objectId)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    SecurityPermissionModel.CreateMap();
                    using (DBEntities context = Settings.CreateDataContext())
                    {
                        SecurityPermission obj =
                            (from p in context.SecurityPermission where p.Id == item.Id select p).FirstOrDefault();
                        if (obj != null)
                        {
                            Mapper.Map(item, obj);
                            obj.GroupId = objectId;
                            context.SaveChanges();
                        }
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Пожалуйста, исправте все ошибки.";
            }

            return(PermissionPartial(objectId));
        }
Ejemplo n.º 2
0
 public ActionResult PermissionAddNewPartial(
     [ModelBinder(typeof(DevExpressEditorsBinder))] SecurityPermissionModel item, Guid objectId)
 {
     if (ModelState.IsValid)
     {
         try
         {
             SecurityPermissionModel.CreateMap();
             using (DBEntities context = Settings.CreateDataContext())
             {
                 SecurityPermission obj = Mapper.Map <SecurityPermissionModel, SecurityPermission>(item);
                 obj.Id      = Guid.NewGuid();
                 obj.GroupId = objectId;
                 context.AddToSecurityPermission(obj);
                 context.SaveChanges();
             }
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Пожалуйста, исправте все ошибки.";
     }
     return(PermissionPartial(objectId));
 }