Exemple #1
0
        // GET: Privilage/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Privilage privilage = db.Privilages.Find(id);

            if (privilage == null)
            {
                return(HttpNotFound());
            }
            return(View(privilage));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Privilage privilage = db.Privilages.Find(id);

            db.Privilages.Remove(privilage);
            int res = db.SaveChanges();

            //return RedirectToAction("Index");
            if (res > 0)
            {
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
Exemple #3
0
        public IActionResult AddPriveleges(int id, [FromForm] int privelegeId)
        {
            try
            {
                Group group = _groupRepositroy.Find(id);
                if (group == null)
                {
                    var message = Messages.NotFound;
                    message.ActionName     = "AddPriveleges";
                    message.ControllerName = "Group";
                    message.Message        = "المجموعة غير موجودة";
                    return(NotFound(message));
                }
                Privilage privilage = _privilageRepositroy.Find(privelegeId);
                if (privilage == null)
                {
                    var message = Messages.NotFound;
                    message.ActionName     = "AddPriveleges";
                    message.ControllerName = "Group";
                    message.Message        = "المجموعة غير موجودة";
                    return(NotFound(message));
                }
                GroupPrivilage groupPrivilage = _groupPrivilageRepositroy.Get(c => c.GroupId == id && c.PrivilageId == privelegeId).FirstOrDefault();
                if (groupPrivilage != null)
                {
                    var message = Messages.Exist;
                    message.ActionName     = "AddPriveleges";
                    message.ControllerName = "Group";
                    return(Conflict(message));
                }
                groupPrivilage = new GroupPrivilage()
                {
                    GroupId     = id,
                    PrivilageId = privelegeId
                };

                _groupPrivilageRepositroy.Add(groupPrivilage, UserName());
                _groupPrivilageRepositroy.Save();
                return(Ok(_mapper.Map <GroupPrivilage>(groupPrivilage)));
            }
            catch
            {
                return(BadRequestAnonymousError());
            }
        }
Exemple #4
0
        public IActionResult RemovePrivilage(int id, [FromForm] int privelegeId)
        {
            try
            {
                Group group = _groupRepositroy.Find(id);
                if (group == null)
                {
                    var message = Messages.NotFound;
                    message.ActionName     = "Remove Privelage";
                    message.ControllerName = "Group";
                    message.Message        = "المجموعة غير موجودة";
                    return(NotFound(message));
                }

                Privilage privilage = _privilageRepositroy.Find(privelegeId);
                if (privilage == null)
                {
                    var message = Messages.NotFound;
                    message.ActionName     = "Remove Privelage";
                    message.ControllerName = "Group";
                    message.Message        = "الصلاحية غير موجودة";
                    return(NotFound(message));
                }
                GroupPrivilage groupPrivilage = _groupPrivilageRepositroy.Get(c => c.GroupId == id && c.PrivilageId == privelegeId).FirstOrDefault();
                if (groupPrivilage == null)
                {
                    var message = Messages.NotFound;
                    message.ActionName     = "Remove Privelage";
                    message.ControllerName = "Group";
                    message.Message        = "مجموعة الصلاحيات غير موجودة";
                    return(Conflict(message));
                }
                _groupPrivilageRepositroy.Remove(groupPrivilage, UserName());
                _groupPrivilageRepositroy.Save();
                return(Ok());
            }
            catch
            {
                return(BadRequestAnonymousError());
            }
        }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "PrivilageID,PrivilageName,Description,Remarks,IsActive,Status,CreateBy,CreateOn,UpdateBy,UpdateOn,IsDeleted,DeleteBy,DeleteOn")] Privilage privilage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(privilage).State = EntityState.Modified;
         int res = db.SaveChanges();
         //return RedirectToAction("Index");
         if (res > 0)
         {
             return(Json("success", JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json("error", JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json("invalid", JsonRequestBehavior.AllowGet));
     }
 }