public IEnumerable <APDIRCircular> GetAPDIRCircular(APDIRCircular aPDIRCircular) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int)); ObjectParameter totalRecord = new ObjectParameter("TotalRecord", typeof(int)); var aPDIRCirculars = dataContext.APDIRCircularGet(aPDIRCircular.APDIRCircularId, aPDIRCircular.MasterDirectionId, aPDIRCircular.Year, Utility.TrimString(aPDIRCircular.SearchText), aPDIRCircular.IsActive, aPDIRCircular.PageNumber, aPDIRCircular.PageSize, aPDIRCircular.IsPagingRequired, Utility.TrimString(aPDIRCircular.OrderBy), Utility.TrimString(aPDIRCircular.OrderByDirection), totalPageCount, totalRecord).ToList(); var aPDIRCircularList = new List <APDIRCircular>(); foreach (var aPDIRCircularDetail in aPDIRCirculars) { aPDIRCircularList.Add(new APDIRCircular() { APDIRCircularId = aPDIRCircularDetail.APDIRCircularId, MasterDirectionId = aPDIRCircularDetail.MasterDirectionId, MasterDirectionName = aPDIRCircularDetail.MasterDIrectionName, APDIRCircularNo = aPDIRCircularDetail.APDIRCircularNo, APDIRCircularName = aPDIRCircularDetail.APDIRCircularName, APDIRCircularDate = aPDIRCircularDetail.APDIRCircularDate, APDIRCircularEffectiveDate = aPDIRCircularDetail.APDIRCircularEffectiveDate, Year = aPDIRCircularDetail.Year, APDIRCircularPDF = aPDIRCircularDetail.PDF, IsActive = aPDIRCircularDetail.IsActive, TotalPageCount = Convert.ToInt32(totalPageCount.Value), TotalRecord = Convert.ToInt32(totalRecord.Value) }); } return(aPDIRCircularList); } }
public int DeleteAPDIRCircular(APDIRCircular aPDIRCircular) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); dataContext.APDIRCircularDelete(aPDIRCircular.APDIRCircularId, aPDIRCircular.ModifiedBy, result); return(Convert.ToInt32(result.Value)); } }
public int UpdateAPDIRCircular(APDIRCircular aPDIRCircular) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); dataContext.APDIRCircularUpdate(aPDIRCircular.APDIRCircularId, aPDIRCircular.MasterDirectionId, Utility.TrimString(aPDIRCircular.APDIRCircularNo), Utility.TrimString(aPDIRCircular.APDIRCircularName), aPDIRCircular.APDIRCircularDate, aPDIRCircular.APDIRCircularEffectiveDate, Utility.TrimString(aPDIRCircular.Year), Utility.TrimString(aPDIRCircular.APDIRCircularPDF), aPDIRCircular.ModifiedBy, result); return(Convert.ToInt32(result.Value)); } }
public IHttpActionResult DeleteAPDIRCircular(DeleteAPDIRCircularRequest deleteAPDIRCircularRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } var aPDIRCircular = new APDIRCircular() { APDIRCircularId = deleteAPDIRCircularRequest.APDIRCircularId, ModifiedBy = Utility.UserId }; int result = iAPDIRCircular.DeleteAPDIRCircular(aPDIRCircular); switch (result) { case 1: responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "APDIRCircular deleted successfully."; break; case -2: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "APDIRCircular doesn't exist."; break; default: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while deleting APDIRCircular."; break; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while deleting APDIRCircular."; Utility.WriteLog("DeleteAPDIRCircular", deleteAPDIRCircularRequest, "Error while deleting APDIRCircular. (APDIRCircularAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult AddAPDIRCircular(AddAPDIRCircularRequest addAPDIRCircularRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var aPDIRCircular = new APDIRCircular() { MasterDirectionId = addAPDIRCircularRequest.MasterDirectionId, APDIRCircularNo = addAPDIRCircularRequest.APDIRCircularNo, APDIRCircularName = addAPDIRCircularRequest.APDIRCircularName, APDIRCircularDate = addAPDIRCircularRequest.APDIRCircularDate, APDIRCircularEffectiveDate = addAPDIRCircularRequest.APDIRCircularEffectiveDate, Year = addAPDIRCircularRequest.Year, APDIRCircularPDF = addAPDIRCircularRequest.APDIRCircularPDF, CreatedBy = Utility.UserId }; int result = iAPDIRCircular.AddAPDIRCircular(aPDIRCircular); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "APDIRCircular added successfully."; } else if (result == -2) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "APDIRCircular alread exists."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding APDIRCircular."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding APDIRCircular."; Utility.WriteLog("AddAPDIRCircular", addAPDIRCircularRequest, "Error while adding APDIRCircular. (APDIRCircularAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult GetAPDIRCircular([FromUri] GetAPDIRCircularRequest getAPDIRCircularRequest) { var responses = new Responses(); try { if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } if (getAPDIRCircularRequest == null) { getAPDIRCircularRequest = new GetAPDIRCircularRequest(); } if (getAPDIRCircularRequest.PageSize == null) { getAPDIRCircularRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]); } var aPDIRCircular = new APDIRCircular() { APDIRCircularId = getAPDIRCircularRequest.APDIRCircularId, MasterDirectionId = getAPDIRCircularRequest.MasterDirectionId, Year = getAPDIRCircularRequest.Year, SearchText = getAPDIRCircularRequest.SearchText, IsActive = getAPDIRCircularRequest.IsActive, PageNumber = getAPDIRCircularRequest.PageNumber, PageSize = Convert.ToInt32(getAPDIRCircularRequest.PageSize), IsPagingRequired = (getAPDIRCircularRequest.PageNumber != null) ? true : false, OrderBy = getAPDIRCircularRequest.OrderBy, OrderByDirection = getAPDIRCircularRequest.OrderByDirection }; var aPDIRCirculars = iAPDIRCircular.GetAPDIRCircular(aPDIRCircular); var aPDIRCircularList = new List <GetAPDIRCircularResponse>(); foreach (var aPDIRCircularDetail in aPDIRCirculars) { aPDIRCircularList.Add(new GetAPDIRCircularResponse() { APDIRCircularId = Convert.ToInt32(aPDIRCircularDetail.APDIRCircularId), MasterDirectionId = aPDIRCircularDetail.MasterDirectionId, MasterDirectionName = aPDIRCircularDetail.MasterDirectionName, APDIRCircularNo = aPDIRCircularDetail.APDIRCircularNo, APDIRCircularName = aPDIRCircularDetail.APDIRCircularName, APDIRCircularDate = aPDIRCircularDetail.APDIRCircularDate, APDIRCircularEffectiveDate = aPDIRCircularDetail.APDIRCircularEffectiveDate, Year = aPDIRCircularDetail.Year, APDIRCircularYearName = Utility.GetAPDIRCircularYear(Convert.ToInt32(aPDIRCircularDetail.Year)).First().APDIRCircularYearName, APDIRCircularPDF = aPDIRCircularDetail.APDIRCircularPDF, IsActive = Convert.ToBoolean(aPDIRCircularDetail.IsActive), CreatedBy = aPDIRCircularDetail.CreatedBy, TotalPageCount = aPDIRCircularDetail.TotalPageCount, TotalRecord = aPDIRCircularDetail.TotalRecord }); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "APDIRCircular retrieved successfully"; responses.Response = aPDIRCircularList; } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while retrieving APDIRCircular."; Utility.WriteLog("GetAPDIRCircular", getAPDIRCircularRequest, "Error while retrieving APDIRCircular. (APDIRCircularUserController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult UpdateAPDIRCircular(UpdateAPDIRCircularRequest updateAPDIRCircularRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } var aPDIRCircular = new APDIRCircular() { APDIRCircularId = updateAPDIRCircularRequest.APDIRCircularId, MasterDirectionId = updateAPDIRCircularRequest.MasterDirectionId, APDIRCircularNo = updateAPDIRCircularRequest.APDIRCircularNo, APDIRCircularName = updateAPDIRCircularRequest.APDIRCircularName, APDIRCircularDate = updateAPDIRCircularRequest.APDIRCircularDate, APDIRCircularEffectiveDate = updateAPDIRCircularRequest.APDIRCircularEffectiveDate, Year = updateAPDIRCircularRequest.Year, APDIRCircularPDF = updateAPDIRCircularRequest.APDIRCircularPDF, ModifiedBy = Utility.UserId }; int result = iAPDIRCircular.UpdateAPDIRCircular(aPDIRCircular); switch (result) { case 1: responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "APDIRCircular updated successfully."; break; case -2: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "APDIRCircular already exists."; break; case -3: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "APDIRCircular doesn't exist."; break; default: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while updating APDIRCircular."; break; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while updating APDIRCircular."; Utility.WriteLog("UpdateAPDIRCircular", updateAPDIRCircularRequest, "Error while updating APDIRCircular. (APDIRCircularAdminController)", ex.ToString()); } return(Ok(responses)); }