Пример #1
0
        public IEnumerable <PressNoteAPDIRCircular> GetPressNoteAPDIRCircular(PressNoteAPDIRCircular pressNoteAPDIRCircular)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var pressNoteAPDIRCirculars = dataContext.PressNoteAPDIRCircularGet(pressNoteAPDIRCircular.PressNoteAPDIRCircularId, pressNoteAPDIRCircular.PressNoteId, Utility.TrimString(pressNoteAPDIRCircular.SearchText), pressNoteAPDIRCircular.IsActive, pressNoteAPDIRCircular.PageNumber, pressNoteAPDIRCircular.PageSize, pressNoteAPDIRCircular.IsPagingRequired, Utility.TrimString(pressNoteAPDIRCircular.OrderBy), Utility.TrimString(pressNoteAPDIRCircular.OrderByDirection), totalPageCount, totalRecord).ToList();

                var pressNoteAPDIRCircularList = new List <PressNoteAPDIRCircular>();
                foreach (var pressNoteAPDIRCircularDetail in pressNoteAPDIRCirculars)
                {
                    pressNoteAPDIRCircularList.Add(new PressNoteAPDIRCircular()
                    {
                        PressNoteAPDIRCircularId = pressNoteAPDIRCircularDetail.PressNoteAPDIRCircularId,
                        PressNoteId                = pressNoteAPDIRCircularDetail.PressNoteId,
                        APDIRCircularId            = pressNoteAPDIRCircularDetail.APDIRCircularId,
                        APDIRCircularNo            = pressNoteAPDIRCircularDetail.APDIRCircularNo,
                        APDIRCircularName          = pressNoteAPDIRCircularDetail.APDIRCircularName,
                        APDIRCircularDate          = pressNoteAPDIRCircularDetail.APDIRCircularDate,
                        APDIRCircularEffectiveDate = pressNoteAPDIRCircularDetail.APDIRCircularEffectiveDate,
                        Year             = pressNoteAPDIRCircularDetail.Year,
                        APDIRCircularPDF = pressNoteAPDIRCircularDetail.PDF,
                        TotalPageCount   = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord      = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(pressNoteAPDIRCircularList);
            }
        }
        public IHttpActionResult UpdatePressNoteAPDIRCircular(UpdatePressNoteAPDIRCircularRequest updatePressNoteAPDIRCircularRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                var pressNoteAPDIRCircular = new PressNoteAPDIRCircular()
                {
                    PressNoteAPDIRCircularId = updatePressNoteAPDIRCircularRequest.PressNoteAPDIRCircularId,
                    PressNoteId     = updatePressNoteAPDIRCircularRequest.PressNoteId,
                    APDIRCircularId = updatePressNoteAPDIRCircularRequest.APDIRCircularId,
                    ModifiedBy      = Utility.UserId
                };
                int result = iPressNoteAPDIRCircular.UpdatePressNoteAPDIRCircular(pressNoteAPDIRCircular);

                switch (result)
                {
                case 1:
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "Press Note APDIRCircular updated successfully.";
                    break;

                case -2:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Press Note APDIRCircular already exists.";
                    break;

                case -3:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Press Note APDIRCircular doesn't exist.";
                    break;

                default:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while updating Press Note APDIRCircular.";
                    break;
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while updating Press Note APDIRCircular.";

                Utility.WriteLog("UpdatePressNoteAPDIRCircular", updatePressNoteAPDIRCircularRequest, "Error while updating Press Note APDIRCircular. (PressNoteAPDIRCircularAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Пример #3
0
        public int DeletePressNoteAPDIRCircular(PressNoteAPDIRCircular pressNoteAPDIRCircular)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.PressNoteAPDIRCircularDelete(pressNoteAPDIRCircular.PressNoteAPDIRCircularId, pressNoteAPDIRCircular.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult AddPressNoteAPDIRCircular(AddPressNoteAPDIRCircularRequest addPressNoteAPDIRCircularRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var pressNoteAPDIRCircular = new PressNoteAPDIRCircular()
                {
                    PressNoteId     = addPressNoteAPDIRCircularRequest.PressNoteId,
                    APDIRCircularId = addPressNoteAPDIRCircularRequest.APDIRCircularId,
                    CreatedBy       = Utility.UserId
                };
                int result = iPressNoteAPDIRCircular.AddPressNoteAPDIRCircular(pressNoteAPDIRCircular);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "Press Note APDIRCircular added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Press Note APDIRCircular alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding Press Note APDIRCircular.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding Press Note APDIRCircular.";

                Utility.WriteLog("AddPressNoteAPDIRCircular", addPressNoteAPDIRCircularRequest, "Error while adding Press Note APDIRCircular. (PressNoteAPDIRCircularAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetPressNoteAPDIRCircular([FromUri] GetPressNoteAPDIRCircularRequest getPressNoteAPDIRCircularRequest)
        {
            var responses = new Responses();

            try
            {
                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                if (getPressNoteAPDIRCircularRequest == null)
                {
                    getPressNoteAPDIRCircularRequest = new GetPressNoteAPDIRCircularRequest();
                }

                if (getPressNoteAPDIRCircularRequest.PageSize == null)
                {
                    getPressNoteAPDIRCircularRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                }

                var pressNoteAPDIRCircular = new PressNoteAPDIRCircular()
                {
                    PressNoteAPDIRCircularId = getPressNoteAPDIRCircularRequest.PressNoteAPDIRCircularId,
                    PressNoteId      = getPressNoteAPDIRCircularRequest.PressNoteId,
                    SearchText       = getPressNoteAPDIRCircularRequest.SearchText,
                    IsActive         = getPressNoteAPDIRCircularRequest.IsActive,
                    PageNumber       = getPressNoteAPDIRCircularRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getPressNoteAPDIRCircularRequest.PageSize),
                    IsPagingRequired = (getPressNoteAPDIRCircularRequest.PageNumber != null) ? true : false,
                    OrderBy          = getPressNoteAPDIRCircularRequest.OrderBy,
                    OrderByDirection = getPressNoteAPDIRCircularRequest.OrderByDirection
                };
                var pressNoteAPDIRCirculars = iPressNoteAPDIRCircular.GetPressNoteAPDIRCircular(pressNoteAPDIRCircular);

                var pressNoteAPDIRCircularList = new List <GetPressNoteAPDIRCircularResponse>();
                foreach (var pressNoteAPDIRCircularDetail in pressNoteAPDIRCirculars)
                {
                    pressNoteAPDIRCircularList.Add(new GetPressNoteAPDIRCircularResponse()
                    {
                        PressNoteAPDIRCircularId = Convert.ToInt32(pressNoteAPDIRCircularDetail.PressNoteAPDIRCircularId),
                        PressNoteId                = pressNoteAPDIRCircularDetail.PressNoteId,
                        APDIRCircularId            = pressNoteAPDIRCircularDetail.APDIRCircularId,
                        APDIRCircularNo            = pressNoteAPDIRCircularDetail.APDIRCircularNo,
                        APDIRCircularName          = pressNoteAPDIRCircularDetail.APDIRCircularName,
                        APDIRCircularDate          = pressNoteAPDIRCircularDetail.APDIRCircularDate,
                        APDIRCircularEffectiveDate = pressNoteAPDIRCircularDetail.APDIRCircularEffectiveDate,
                        Year             = pressNoteAPDIRCircularDetail.Year,
                        APDIRCircularPDF = pressNoteAPDIRCircularDetail.APDIRCircularPDF,
                        IsActive         = Convert.ToBoolean(pressNoteAPDIRCircularDetail.IsActive),
                        CreatedBy        = pressNoteAPDIRCircularDetail.CreatedBy,
                        TotalPageCount   = pressNoteAPDIRCircularDetail.TotalPageCount,
                        TotalRecord      = pressNoteAPDIRCircularDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "Press Note APDIRCircular retrieved successfully";
                responses.Response    = pressNoteAPDIRCircularList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving Press Note APDIRCircular.";

                Utility.WriteLog("GetPressNoteAPDIRCircular", getPressNoteAPDIRCircularRequest, "Error while retrieving Press Note APDIRCircular. (PressNoteAPDIRCircularAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }