public IEnumerable <GSRNotification> GetGSRNotification(GSRNotification gSRNotification) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int)); ObjectParameter totalRecord = new ObjectParameter("TotalRecord", typeof(int)); var gSRNotifications = dataContext.GSRNotificationGet(gSRNotification.GSRNotificationId, gSRNotification.RulesId, Utility.TrimString(gSRNotification.SearchText), gSRNotification.IsActive, gSRNotification.PageNumber, gSRNotification.PageSize, gSRNotification.IsPagingRequired, Utility.TrimString(gSRNotification.OrderBy), Utility.TrimString(gSRNotification.OrderByDirection), totalPageCount, totalRecord).ToList(); var gSRNotificationList = new List <GSRNotification>(); foreach (var gSRNotificationDetail in gSRNotifications) { gSRNotificationList.Add(new GSRNotification() { GSRNotificationId = gSRNotificationDetail.GSRNotificationId, RulesId = gSRNotificationDetail.RulesId, GSRNotificationNo = gSRNotificationDetail.GSRNotificationNo, RulesName = gSRNotificationDetail.NameofRules, GSRNotificationName = gSRNotificationDetail.GSRNotificationName, GSRNotificationTypeName = gSRNotificationDetail.GSRNotificationTypeName, GSRNotificationDate = gSRNotificationDetail.GSRNotificationDate, GSRNotificationEffectiveDate = gSRNotificationDetail.GSRNotificationEffectiveDate, GSRNotificationTypeId = gSRNotificationDetail.GSRNotificationTypeId, PDF = gSRNotificationDetail.PDF, IsActive = gSRNotificationDetail.IsActive, TotalPageCount = Convert.ToInt32(totalPageCount.Value), TotalRecord = Convert.ToInt32(totalRecord.Value) }); } return(gSRNotificationList); } }
public int DeleteGSRNotification(GSRNotification gSRNotification) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); dataContext.GSRNotificationDelete(gSRNotification.GSRNotificationId, gSRNotification.ModifiedBy, result); return(Convert.ToInt32(result.Value)); } }
public int UpdateGSRNotification(GSRNotification gSRNotification) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); dataContext.GSRNotificationUpdate(gSRNotification.GSRNotificationId, gSRNotification.RulesId, Utility.TrimString(gSRNotification.GSRNotificationNo), Utility.TrimString(gSRNotification.GSRNotificationName), gSRNotification.GSRNotificationDate, gSRNotification.GSRNotificationEffectiveDate, gSRNotification.GSRNotificationTypeId, Utility.TrimString(gSRNotification.PDF), gSRNotification.ModifiedBy, result); return(Convert.ToInt32(result.Value)); } }
public IHttpActionResult DeleteGSRNotification(DeleteGSRNotificationRequest deleteGSRNotificationRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } var gSRNotification = new GSRNotification() { GSRNotificationId = deleteGSRNotificationRequest.GSRNotificationId, ModifiedBy = Utility.UserId }; int result = iGSRNotification.DeleteGSRNotification(gSRNotification); switch (result) { case 1: responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "GSRNotification deleted successfully."; break; case -2: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "GSRNotification doesn't exist."; break; default: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while deleting GSRNotification."; break; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while deleting GSRNotification."; Utility.WriteLog("DeleteGSRNotification", deleteGSRNotificationRequest, "Error while deleting GSRNotification. (GSRNotificationAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult AddGSRNotification(AddGSRNotificationRequest addGSRNotificationRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var gSRNotification = new GSRNotification() { RulesId = addGSRNotificationRequest.RulesId, GSRNotificationNo = addGSRNotificationRequest.GSRNotificationNo, GSRNotificationName = addGSRNotificationRequest.GSRNotificationName, GSRNotificationDate = addGSRNotificationRequest.GSRNotificationDate, GSRNotificationEffectiveDate = addGSRNotificationRequest.GSRNotificationEffectiveDate, GSRNotificationTypeId = addGSRNotificationRequest.GSRNotificationTypeId, PDF = addGSRNotificationRequest.PDF, CreatedBy = Utility.UserId }; int result = iGSRNotification.AddGSRNotification(gSRNotification); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "GSRNotification added successfully."; } else if (result == -2) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "GSRNotification alread exists."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding GSRNotification."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding GSRNotification."; Utility.WriteLog("AddGSRNotification", addGSRNotificationRequest, "Error while adding GSRNotification. (GSRNotificationAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult GetGSRNotification([FromUri] GetGSRNotificationRequest getGSRNotificationRequest) { var responses = new Responses(); try { if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } if (getGSRNotificationRequest == null) { getGSRNotificationRequest = new GetGSRNotificationRequest(); } if (getGSRNotificationRequest.PageSize == null) { getGSRNotificationRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]); } var gSRNotification = new GSRNotification() { GSRNotificationId = getGSRNotificationRequest.GSRNotificationId, RulesId = getGSRNotificationRequest.RulesId, SearchText = getGSRNotificationRequest.SearchText, IsActive = getGSRNotificationRequest.IsActive, PageNumber = getGSRNotificationRequest.PageNumber, PageSize = Convert.ToInt32(getGSRNotificationRequest.PageSize), IsPagingRequired = (getGSRNotificationRequest.PageNumber != null) ? true : false, OrderBy = getGSRNotificationRequest.OrderBy, OrderByDirection = getGSRNotificationRequest.OrderByDirection }; var gSRNotifications = iGSRNotification.GetGSRNotification(gSRNotification); var gSRNotificationList = new List <GetGSRNotificationResponse>(); foreach (var gSRNotificationDetail in gSRNotifications) { gSRNotificationList.Add(new GetGSRNotificationResponse() { GSRNotificationId = gSRNotificationDetail.GSRNotificationId, RulesId = gSRNotificationDetail.RulesId, GSRNotificationNo = gSRNotificationDetail.GSRNotificationNo, RulesName = gSRNotificationDetail.RulesName, GSRNotificationName = gSRNotificationDetail.GSRNotificationName, GSRNotificationTypeName = gSRNotificationDetail.GSRNotificationTypeName, GSRNotificationDate = gSRNotificationDetail.GSRNotificationDate, GSRNotificationEffectiveDate = gSRNotificationDetail.GSRNotificationEffectiveDate, GSRNotificationTypeId = gSRNotificationDetail.GSRNotificationTypeId, PDF = gSRNotificationDetail.PDF, IsActive = Convert.ToBoolean(gSRNotificationDetail.IsActive), CreatedBy = gSRNotificationDetail.CreatedBy, TotalPageCount = gSRNotificationDetail.TotalPageCount, TotalRecord = gSRNotificationDetail.TotalRecord }); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "GSRNotification retrieved successfully"; responses.Response = gSRNotificationList; } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while retrieving GSRNotification."; Utility.WriteLog("GetGSRNotification", getGSRNotificationRequest, "Error while retrieving GSRNotification. (GSRNotificationAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult UpdateGSRNotification(UpdateGSRNotificationRequest updateGSRNotificationRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } var gSRNotification = new GSRNotification() { GSRNotificationId = updateGSRNotificationRequest.GSRNotificationId, RulesId = updateGSRNotificationRequest.RulesId, GSRNotificationNo = updateGSRNotificationRequest.GSRNotificationNo, GSRNotificationName = updateGSRNotificationRequest.GSRNotificationName, GSRNotificationDate = updateGSRNotificationRequest.GSRNotificationDate, GSRNotificationEffectiveDate = updateGSRNotificationRequest.GSRNotificationEffectiveDate, GSRNotificationTypeId = updateGSRNotificationRequest.GSRNotificationTypeId, PDF = updateGSRNotificationRequest.PDF, ModifiedBy = Utility.UserId }; int result = iGSRNotification.UpdateGSRNotification(gSRNotification); switch (result) { case 1: responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "GSRNotification updated successfully."; break; case -2: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "GSRNotification already exists."; break; case -3: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "GSRNotification doesn't exist."; break; default: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while updating GSRNotification."; break; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while updating GSRNotification."; Utility.WriteLog("UpdateGSRNotification", updateGSRNotificationRequest, "Error while updating GSRNotification. (GSRNotificationAdminController)", ex.ToString()); } return(Ok(responses)); }