Exemplo n.º 1
0
        public IEnumerable <MasterDirectionChapter> GetMasterDirectionChapter(MasterDirectionChapter masterDirectionChapter)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var masterDirectionChapters = dataContext.MasterDirectionChapterGet(masterDirectionChapter.MasterDirectionChapterId, masterDirectionChapter.MasterDirectionId, Utility.TrimString(masterDirectionChapter.SearchText), masterDirectionChapter.IsActive, masterDirectionChapter.PageNumber, masterDirectionChapter.PageSize, masterDirectionChapter.IsPagingRequired, Utility.TrimString(masterDirectionChapter.OrderBy), Utility.TrimString(masterDirectionChapter.OrderByDirection), totalPageCount, totalRecord).ToList();

                var masterDirectionChapterList = new List <MasterDirectionChapter>();
                foreach (var masterDirectionChapterDetail in masterDirectionChapters)
                {
                    masterDirectionChapterList.Add(new MasterDirectionChapter()
                    {
                        MasterDirectionId        = masterDirectionChapterDetail.MDID,
                        MasterDirectionChapterId = masterDirectionChapterDetail.MDPID,
                        Chapter        = masterDirectionChapterDetail.PartData,
                        SortId         = masterDirectionChapterDetail.SortId,
                        IsActive       = masterDirectionChapterDetail.IsActive,
                        TotalPageCount = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord    = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(masterDirectionChapterList);
            }
        }
        public IHttpActionResult UpdateMasterDirectionChapter(UpdateMasterDirectionChapterRequest updateMasterDirectionChapterRequest)
        {
            var responses = new Responses();

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

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

                var masterDirectionChapter = new MasterDirectionChapter()
                {
                    MasterDirectionChapterId = updateMasterDirectionChapterRequest.MasterDirectionChapterId,
                    MasterDirectionId        = updateMasterDirectionChapterRequest.MasterDirectionId,
                    Chapter            = updateMasterDirectionChapterRequest.Chapter,
                    SaveAfterChapterId = updateMasterDirectionChapterRequest.SaveAfterChapterId,
                    ModifiedBy         = Utility.UserId
                };
                int result = iMasterDirectionChapter.UpdateMasterDirectionChapter(masterDirectionChapter);

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

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

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

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

                Utility.WriteLog("UpdateMasterDirectionChapter", updateMasterDirectionChapterRequest, "Error while updating MasterDirectionChapter. (MasterDirectionChapterAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Exemplo n.º 3
0
        public int DeleteMasterDirectionChapter(MasterDirectionChapter masterDirectionChapter)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.MasterDirectionChapterDelete(masterDirectionChapter.MasterDirectionChapterId, masterDirectionChapter.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
Exemplo n.º 4
0
        public int UpdateMasterDirectionChapter(MasterDirectionChapter masterDirectionChapter)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.MasterDirectionChapterUpdate(masterDirectionChapter.MasterDirectionChapterId, masterDirectionChapter.MasterDirectionId, Utility.TrimString(masterDirectionChapter.Chapter), masterDirectionChapter.SaveAfterChapterId, masterDirectionChapter.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult AddMasterDirectionChapter(AddMasterDirectionChapterRequest addMasterDirectionChapterRequest)
        {
            var responses = new Responses();

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

                var masterDirectionChapter = new MasterDirectionChapter()
                {
                    MasterDirectionId  = addMasterDirectionChapterRequest.MasterDirectionId,
                    Chapter            = addMasterDirectionChapterRequest.Chapter,
                    SaveAfterChapterId = addMasterDirectionChapterRequest.SaveAfterChapterId,
                    CreatedBy          = Utility.UserId
                };
                int result = iMasterDirectionChapter.AddMasterDirectionChapter(masterDirectionChapter);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "MasterDirectionChapter added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "MasterDirectionChapter alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding MasterDirectionChapter.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding MasterDirectionChapter.";

                Utility.WriteLog("AddMasterDirectionChapter", addMasterDirectionChapterRequest, "Error while adding MasterDirectionChapter. (MasterDirectionChapterAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetMasterDirectionChapter([FromUri] GetMasterDirectionChapterRequest getMasterDirectionChapterRequest)
        {
            var responses = new Responses();

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

                if (getMasterDirectionChapterRequest == null)
                {
                    getMasterDirectionChapterRequest = new GetMasterDirectionChapterRequest();
                }

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

                var masterDirectionChapter = new MasterDirectionChapter()
                {
                    MasterDirectionChapterId = getMasterDirectionChapterRequest.MasterDirectionChapterId,
                    MasterDirectionId        = getMasterDirectionChapterRequest.MasterDirectionId,
                    SearchText       = getMasterDirectionChapterRequest.SearchText,
                    IsActive         = getMasterDirectionChapterRequest.IsActive,
                    PageNumber       = getMasterDirectionChapterRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getMasterDirectionChapterRequest.PageSize),
                    IsPagingRequired = (getMasterDirectionChapterRequest.PageNumber != null) ? true : false,
                    OrderBy          = getMasterDirectionChapterRequest.OrderBy,
                    OrderByDirection = getMasterDirectionChapterRequest.OrderByDirection
                };
                var masterDirectionChapters = iMasterDirectionChapter.GetMasterDirectionChapter(masterDirectionChapter).OrderBy(x => x.SortId).ToList();

                var masterDirectionChapterList = new List <GetMasterDirectionChapterResponse>();
                foreach (var masterDirectionChapterDetail in masterDirectionChapters)
                {
                    masterDirectionChapterList.Add(new GetMasterDirectionChapterResponse()
                    {
                        MasterDirectionId        = Convert.ToInt32(masterDirectionChapterDetail.MasterDirectionId),
                        MasterDirectionChapterId = Convert.ToInt32(masterDirectionChapterDetail.MasterDirectionChapterId),
                        Chapter        = masterDirectionChapterDetail.Chapter,
                        SortId         = masterDirectionChapterDetail.SortId,
                        IsActive       = Convert.ToBoolean(masterDirectionChapterDetail.IsActive),
                        CreatedBy      = masterDirectionChapterDetail.CreatedBy,
                        TotalPageCount = masterDirectionChapterDetail.TotalPageCount,
                        TotalRecord    = masterDirectionChapterDetail.TotalRecord
                    });
                }

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

                Utility.WriteLog("GetMasterDirectionChapter", getMasterDirectionChapterRequest, "Error while retrieving MasterDirectionChapter. (MasterDirectionOfFEMASubModuleDetailUserController)", ex.ToString());
            }
            return(Ok(responses));
        }