Ejemplo n.º 1
0
        public HttpResponseMessage GetRoleById(int role_id)//r_id role_id
        {
            HttpResponseMessage response = null;

            try
            {
                if (role_id != 0)
                {
                    RoleModel instance = RoleRepo.GetRoleById(role_id);
                    if (instance != null)
                    {
                        response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Success", instance));
                    }
                    else
                    {
                        response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_702", "Invalid role ID", "Invalid role ID"));
                    }
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json"));
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message));
            }
            return(response);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage DeleteRoleById(int role_id)//r_id role_id
        {
            HttpResponseMessage response = null;

            try
            {
                if (role_id != 0)
                {
                    if (RoleRepo.GetRoleById(role_id) != null)
                    {
                        RoleRepo.DeleteRoleById(role_id);
                        response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Role deleted successfully!", "Role deleted successfully!"));
                    }
                    else
                    {
                        response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_702", "Invalid role object", "Invalid role object"));
                    }
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json"));
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message));
            }
            return(response);
        }
Ejemplo n.º 3
0
        public ActionResult GetRoleById(RoleViewModel rViewModel)
        {
            try
            {
                rViewModel.Role = _rRepo.GetRoleById(rViewModel.Role.RoleId);

                rViewModel.Role.Modules = _rRepo.GetModuleByRoleId(rViewModel.Role.RoleId);
            }
            catch (Exception ex)
            {
                rViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Role Controller - GetRoleById" + ex.ToString());
            }

            TempData["rViewModel"] = rViewModel;

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public RoleInfo GetRoleById(int roleid)
 {
     return(_roleRepo.GetRoleById(roleid));
 }