public ActionResult GetClinicPoliData() { var _draw = Request.Form.GetValues("draw").FirstOrDefault(); var _start = Request.Form.GetValues("start").FirstOrDefault(); var _length = Request.Form.GetValues("length").FirstOrDefault(); var _sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); var _sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); var _searchValue = Request.Form.GetValues("search[value]").FirstOrDefault(); int _pageSize = _length != null?Convert.ToInt32(_length) : 0; int _skip = _start != null?Convert.ToInt32(_start) : 0; var request = new PoliRequest { Draw = _draw, SearchValue = _searchValue, SortColumn = _sortColumn, SortColumnDir = _sortColumnDir, PageSize = _pageSize, Skip = _skip }; var response = new PoliHandler(_unitOfWork).GetListData(request); return(Json(new { data = response.Data, recordsFiltered = response.RecordsFiltered, recordsTotal = response.RecordsTotal, draw = response.Draw }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Validate request /// </summary> /// <param name="request"></param> /// <param name="response"></param> public void Validate(PoliRequest request, out PoliResponse response) { response = new PoliResponse(); if (request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString())) { ValidateForDelete(request, out response); } else { bool isHavePrivilege = true; if (request.Data.Name == null || String.IsNullOrWhiteSpace(request.Data.Name)) { errorFields.Add("Poli Name"); } if (request.Data.Type == 0) { errorFields.Add("Type"); } if (errorFields.Any()) { response.Status = false; response.Message = string.Format(Messages.ValidationErrorFields, String.Join(",", errorFields)); } else if (request.Data.Name.Length > 30) { response.Status = false; response.Message = $"Maximum Character for Poli Name is 30"; } if (request.Data.Id == 0) { isHavePrivilege = IsHaveAuthorization(ADD_POLI_NAME, request.Data.Account.Privileges.PrivilegeIDs); } else { isHavePrivilege = IsHaveAuthorization(EDIT_POLI_NAME, request.Data.Account.Privileges.PrivilegeIDs); } if (!isHavePrivilege) { response.Status = false; response.Message = Messages.UnauthorizedAccess; } if (response.Status) { response = new PoliHandler(_unitOfWork).CreateOrEdit(request); } } }
/// <summary> /// Delete validation /// </summary> /// <param name="request"></param> /// <param name="response"></param> private void ValidateForDelete(PoliRequest request, out PoliResponse response) { response = new PoliResponse(); if (request.Action == ClinicEnums.Action.DELETE.ToString()) { bool isHavePrivilege = IsHaveAuthorization(DELETE_POLI_NAME, request.Data.Account.Privileges.PrivilegeIDs); if (!isHavePrivilege) { response.Status = false; response.Message = Messages.UnauthorizedAccess; } } if (response.Status) { response = new PoliHandler(_unitOfWork).RemoveData(request); } }