Esempio n. 1
0
        public IEnumerable <PressNote> GetPressNote(PressNote pressNote)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var pressNotes = dataContext.PressNoteGet(pressNote.PressNoteId, Utility.TrimString(pressNote.Year), Utility.TrimString(pressNote.SearchText), pressNote.IsActive, pressNote.PageNumber, pressNote.PageSize, pressNote.IsPagingRequired, Utility.TrimString(pressNote.OrderBy), Utility.TrimString(pressNote.OrderByDirection), totalPageCount, totalRecord).ToList();

                var pressNoteList = new List <PressNote>();
                foreach (var pressNoteDetail in pressNotes)
                {
                    pressNoteList.Add(new PressNote()
                    {
                        PressNoteId            = pressNoteDetail.PressNoteId,
                        PressNoteNo            = pressNoteDetail.PressNoteNo,
                        PressNoteName          = pressNoteDetail.PressNoteName,
                        PressNoteDate          = pressNoteDetail.PressNoteDate,
                        PressNoteEffectiveDate = pressNoteDetail.PressNoteEffectiveDate,
                        Year           = pressNoteDetail.Year,
                        PressNotePDF   = pressNoteDetail.PDF,
                        IsActive       = pressNoteDetail.IsActive,
                        TotalPageCount = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord    = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(pressNoteList);
            }
        }
Esempio n. 2
0
        public int DeletePressNote(PressNote pressNote)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.PressNoteDelete(pressNote.PressNoteId, pressNote.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
Esempio n. 3
0
        public int UpdatePressNote(PressNote pressNote)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.PressNoteUpdate(pressNote.PressNoteId, Utility.TrimString(pressNote.PressNoteNo), Utility.TrimString(pressNote.PressNoteName), pressNote.PressNoteDate, pressNote.PressNoteEffectiveDate, Utility.TrimString(pressNote.Year), Utility.TrimString(pressNote.PressNotePDF), pressNote.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult DeletePressNote(DeletePressNoteRequest deletePressNoteRequest)
        {
            var responses = new Responses();

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

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

                var pressNote = new PressNote()
                {
                    PressNoteId = deletePressNoteRequest.PressNoteId,
                    ModifiedBy  = Utility.UserId
                };

                int result = iPressNote.DeletePressNote(pressNote);
                switch (result)
                {
                case 1:
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "PressNote deleted successfully.";
                    break;

                case -2:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "PressNote doesn't exist.";
                    break;

                default:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while deleting PressNote.";
                    break;
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while deleting PressNote.";

                Utility.WriteLog("DeletePressNote", deletePressNoteRequest, "Error while deleting PressNote. (PressNoteAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult AddPressNote(AddPressNoteRequest addPressNoteRequest)
        {
            var responses = new Responses();

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

                var pressNote = new PressNote()
                {
                    PressNoteNo            = addPressNoteRequest.PressNoteNo,
                    PressNoteName          = addPressNoteRequest.PressNoteName,
                    PressNoteDate          = addPressNoteRequest.PressNoteDate,
                    PressNoteEffectiveDate = addPressNoteRequest.PressNoteEffectiveDate,
                    Year         = addPressNoteRequest.Year,
                    PressNotePDF = addPressNoteRequest.PressNotePDF,
                    CreatedBy    = Utility.UserId
                };
                int result = iPressNote.AddPressNote(pressNote);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "PressNote added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "PressNote alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding PressNote.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding PressNote.";

                Utility.WriteLog("AddPressNote", addPressNoteRequest, "Error while adding PressNote. (PressNoteAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Esempio n. 6
0
        public IHttpActionResult GetPressNote([FromUri] GetPressNoteRequest getPressNoteRequest)
        {
            var responses = new Responses();

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

                if (getPressNoteRequest == null)
                {
                    getPressNoteRequest = new GetPressNoteRequest();
                }

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

                var pressNote = new PressNote()
                {
                    PressNoteId      = getPressNoteRequest.PressNoteId,
                    Year             = getPressNoteRequest.Year,
                    SearchText       = getPressNoteRequest.SearchText,
                    IsActive         = getPressNoteRequest.IsActive,
                    PageNumber       = getPressNoteRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getPressNoteRequest.PageSize),
                    IsPagingRequired = (getPressNoteRequest.PageNumber != null) ? true : false,
                    OrderBy          = getPressNoteRequest.OrderBy,
                    OrderByDirection = getPressNoteRequest.OrderByDirection
                };
                var pressNotes = iPressNote.GetPressNote(pressNote);

                var pressNoteList = new List <GetPressNoteResponse>();
                foreach (var pressNoteDetail in pressNotes)
                {
                    pressNoteList.Add(new GetPressNoteResponse()
                    {
                        PressNoteId            = Convert.ToInt32(pressNoteDetail.PressNoteId),
                        PressNoteNo            = pressNoteDetail.PressNoteNo,
                        PressNoteName          = pressNoteDetail.PressNoteName,
                        PressNoteDate          = pressNoteDetail.PressNoteDate,
                        PressNoteEffectiveDate = pressNoteDetail.PressNoteEffectiveDate,
                        Year           = pressNoteDetail.Year,
                        PressNotePDF   = pressNoteDetail.PressNotePDF,
                        IsActive       = Convert.ToBoolean(pressNoteDetail.IsActive),
                        CreatedBy      = pressNoteDetail.CreatedBy,
                        TotalPageCount = pressNoteDetail.TotalPageCount,
                        TotalRecord    = pressNoteDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "PressNote retrieved successfully";
                responses.Response    = pressNoteList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving PressNote.";

                Utility.WriteLog("GetPressNote", getPressNoteRequest, "Error while retrieving PressNote. (PressNoteUserController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult UpdatePressNote(UpdatePressNoteRequest updatePressNoteRequest)
        {
            var responses = new Responses();

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

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

                var pressNote = new PressNote()
                {
                    PressNoteId            = updatePressNoteRequest.PressNoteId,
                    PressNoteNo            = updatePressNoteRequest.PressNoteNo,
                    PressNoteName          = updatePressNoteRequest.PressNoteName,
                    PressNoteDate          = updatePressNoteRequest.PressNoteDate,
                    PressNoteEffectiveDate = updatePressNoteRequest.PressNoteEffectiveDate,
                    Year         = updatePressNoteRequest.Year,
                    PressNotePDF = updatePressNoteRequest.PressNotePDF,
                    ModifiedBy   = Utility.UserId
                };
                int result = iPressNote.UpdatePressNote(pressNote);

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

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

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

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

                Utility.WriteLog("UpdatePressNote", updatePressNoteRequest, "Error while updating PressNote. (PressNoteAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }