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

                var indexAmendments = dataContext.IndexAmendmentGet(indexAmendment.IndexAmendmentId, indexAmendment.RegulationId, Utility.TrimString(indexAmendment.SearchText), indexAmendment.IsActive, indexAmendment.PageNumber, indexAmendment.PageSize, indexAmendment.IsPagingRequired, Utility.TrimString(indexAmendment.OrderBy), Utility.TrimString(indexAmendment.OrderByDirection), totalPageCount, totalRecord).ToList();

                var indexAmendmentList = new List <IndexAmendment>();
                foreach (var indexAmendmentDetail in indexAmendments)
                {
                    indexAmendmentList.Add(new IndexAmendment()
                    {
                        IndexAmendmentId      = indexAmendmentDetail.IndexAmendmentId,
                        RegulationId          = indexAmendmentDetail.RegulationId,
                        NotificationIds       = indexAmendmentDetail.NotificationIds,
                        Notifications         = indexAmendmentDetail.Notifications,
                        RegulationName        = indexAmendmentDetail.Regulationname,
                        RegulationNumber      = indexAmendmentDetail.Regulationnumber,
                        IndexId               = indexAmendmentDetail.IndexId,
                        IndexNo               = indexAmendmentDetail.IndexNo,
                        IndexName             = indexAmendmentDetail.Indexname,
                        SubIndexId            = indexAmendmentDetail.SubIndexId,
                        SubIndexNumber        = indexAmendmentDetail.SubIndexNumber,
                        SubIndexName          = indexAmendmentDetail.SubIndexName,
                        IndexAmendmentContent = indexAmendmentDetail.IndexAmendmentContent,
                        IsActive              = indexAmendmentDetail.IsActive,
                        TotalPageCount        = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord           = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(indexAmendmentList);
            }
        }
        public IHttpActionResult UpdateIndexAmendment(UpdateIndexAmendmentRequest updateIndexAmendmentRequest)
        {
            var responses = new Responses();

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

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

                var indexAmendment = new IndexAmendment()
                {
                    IndexAmendmentId      = updateIndexAmendmentRequest.IndexAmendmentId,
                    RegulationId          = updateIndexAmendmentRequest.RegulationId,
                    NotificationIds       = updateIndexAmendmentRequest.NotificationIds,
                    IndexId               = updateIndexAmendmentRequest.IndexId,
                    SubIndexId            = updateIndexAmendmentRequest.SubIndexId,
                    IndexAmendmentContent = updateIndexAmendmentRequest.IndexAmendmentContent,
                    ModifiedBy            = Utility.UserId
                };
                int result = iIndexAmendment.UpdateIndexAmendment(indexAmendment);

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

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

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

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

                Utility.WriteLog("UpdateIndexAmendment", updateIndexAmendmentRequest, "Error while updating index amendment. (IndexAmendmentAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Exemplo n.º 3
0
        public int DeleteIndexAmendment(IndexAmendment indexAmendment)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.IndexAmendmentDelete(indexAmendment.IndexAmendmentId, indexAmendment.ModifiedBy, result);

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

                dataContext.IndexAmendmentUpdate(indexAmendment.IndexAmendmentId, indexAmendment.RegulationId, indexAmendment.NotificationIds, indexAmendment.IndexId, indexAmendment.SubIndexId, Utility.TrimString(indexAmendment.IndexAmendmentContent), indexAmendment.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult AddIndexAmendment(AddIndexAmendmentRequest addIndexAmendmentRequest)
        {
            var responses = new Responses();

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

                var indexAmendment = new IndexAmendment()
                {
                    RegulationId          = addIndexAmendmentRequest.RegulationId,
                    NotificationIds       = addIndexAmendmentRequest.NotificationIds,
                    IndexId               = addIndexAmendmentRequest.IndexId,
                    SubIndexId            = addIndexAmendmentRequest.SubIndexId,
                    IndexAmendmentContent = addIndexAmendmentRequest.IndexAmendmentContent
                };
                int result = iIndexAmendment.AddIndexAmendment(indexAmendment);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "IndexAmendment added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "IndexAmendment alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding index amendment.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding index amendment.";

                Utility.WriteLog("AddIndexAmendment", addIndexAmendmentRequest, "Error while adding index amendment. (IndexAmendmentAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetIndexAmendment([FromUri] GetIndexAmendmentRequest getIndexAmendmentRequest)
        {
            var responses = new Responses();

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

                if (getIndexAmendmentRequest == null)
                {
                    getIndexAmendmentRequest = new GetIndexAmendmentRequest();
                }

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

                var indexAmendment = new IndexAmendment()
                {
                    IndexAmendmentId = getIndexAmendmentRequest.IndexAmendmentId,
                    RegulationId     = getIndexAmendmentRequest.RegulationId,
                    SearchText       = getIndexAmendmentRequest.SearchText,
                    IsActive         = getIndexAmendmentRequest.IsActive,
                    PageNumber       = getIndexAmendmentRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getIndexAmendmentRequest.PageSize),
                    IsPagingRequired = (getIndexAmendmentRequest.PageNumber != null) ? true : false,
                    OrderBy          = getIndexAmendmentRequest.OrderBy,
                    OrderByDirection = getIndexAmendmentRequest.OrderByDirection
                };
                var indexAmendments = iIndexAmendment.GetIndexAmendment(indexAmendment);

                var indexAmendmentList = new List <GetIndexAmendmentResponse>();
                foreach (var indexAmendmentDetail in indexAmendments)
                {
                    indexAmendmentList.Add(new GetIndexAmendmentResponse()
                    {
                        IndexAmendmentId      = indexAmendmentDetail.IndexAmendmentId,
                        RegulationId          = indexAmendmentDetail.RegulationId,
                        NotificationIds       = indexAmendmentDetail.NotificationIds,
                        Notifications         = indexAmendmentDetail.Notifications,
                        RegulationName        = indexAmendmentDetail.RegulationName,
                        RegulationNumber      = indexAmendmentDetail.RegulationNumber,
                        IndexId               = indexAmendmentDetail.IndexId,
                        IndexNo               = indexAmendmentDetail.IndexNo,
                        IndexName             = indexAmendmentDetail.IndexName,
                        SubIndexId            = indexAmendmentDetail.SubIndexId,
                        SubIndexNumber        = indexAmendmentDetail.SubIndexNumber,
                        SubIndexName          = indexAmendmentDetail.SubIndexName,
                        IndexAmendmentContent = indexAmendmentDetail.IndexAmendmentContent,
                        IsActive              = Convert.ToBoolean(indexAmendmentDetail.IsActive),
                        CreatedBy             = indexAmendmentDetail.CreatedBy,
                        TotalPageCount        = indexAmendmentDetail.TotalPageCount,
                        TotalRecord           = indexAmendmentDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "IndexAmendment retrieved successfully";
                responses.Response    = indexAmendmentList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving index amendment.";

                Utility.WriteLog("GetIndexAmendment", getIndexAmendmentRequest, "Error while retrieving index amendment. (FEMASubModuleDetailUserController)", ex.ToString());
            }
            return(Ok(responses));
        }