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

                var rBIDatas = dataContext.RBIDataGet(rBIData.RBIDataId, Utility.TrimString(rBIData.SearchText), rBIData.IsActive, rBIData.PageNumber, rBIData.PageSize, rBIData.IsPagingRequired, Utility.TrimString(rBIData.OrderBy), Utility.TrimString(rBIData.OrderByDirection), totalPageCount, totalRecord).ToList();

                var rBIDataList = new List <RBIData>();
                foreach (var rBIDataDetail in rBIDatas)
                {
                    rBIDataList.Add(new RBIData()
                    {
                        RBIDataId      = rBIDataDetail.RBIDataId,
                        RBIDataName    = rBIDataDetail.RBIDataName,
                        Excel          = rBIDataDetail.Excel,
                        IsActive       = rBIDataDetail.IsActive,
                        TotalPageCount = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord    = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(rBIDataList);
            }
        }
        public IHttpActionResult UpdateRBIData(UpdateRBIDataRequest updateRBIDataRequest)
        {
            var responses = new Responses();

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

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

                var rBIData = new RBIData()
                {
                    RBIDataId   = updateRBIDataRequest.RBIDataId,
                    RBIDataName = updateRBIDataRequest.RBIDataName,
                    Excel       = updateRBIDataRequest.Excel,
                    ModifiedBy  = Utility.UserId
                };
                int result = iRBIData.UpdateRBIData(rBIData);

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

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

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

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

                Utility.WriteLog("UpdateRBIData", updateRBIDataRequest, "Error while updating rbidata. (RBIDataAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Пример #3
0
        public int DeleteRBIData(RBIData rBIData)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.RBIDataDelete(rBIData.RBIDataId, rBIData.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
Пример #4
0
        public int UpdateRBIData(RBIData rBIData)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.RBIDataUpdate(rBIData.RBIDataId, Utility.TrimString(rBIData.RBIDataName), Utility.TrimString(rBIData.Excel), rBIData.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult AddRBIData(AddRBIDataRequest addRBIDataRequest)
        {
            var responses = new Responses();

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

                var rBIData = new RBIData()
                {
                    RBIDataName = addRBIDataRequest.RBIDataName,
                    Excel       = addRBIDataRequest.Excel,
                    CreatedBy   = Utility.UserId
                };
                int result = iRBIData.AddRBIData(rBIData);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "RBIData added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "RBIData alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding rbidata.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding rbidata.";

                Utility.WriteLog("AddRBIData", addRBIDataRequest, "Error while adding rbidata. (RBIDataAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetRBIData([FromUri] GetRBIDataRequest getRBIDataRequest)
        {
            var responses = new Responses();

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

                if (getRBIDataRequest == null)
                {
                    getRBIDataRequest = new GetRBIDataRequest();
                }

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

                var rBIData = new RBIData()
                {
                    RBIDataId        = getRBIDataRequest.RBIDataId,
                    SearchText       = getRBIDataRequest.SearchText,
                    IsActive         = getRBIDataRequest.IsActive,
                    PageNumber       = getRBIDataRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getRBIDataRequest.PageSize),
                    IsPagingRequired = (getRBIDataRequest.PageNumber != null) ? true : false,
                    OrderBy          = getRBIDataRequest.OrderBy,
                    OrderByDirection = getRBIDataRequest.OrderByDirection
                };
                var rBIDatas = iRBIData.GetRBIData(rBIData);

                var rBIDataList = new List <GetRBIDataResponse>();
                foreach (var rBIDataDetail in rBIDatas)
                {
                    rBIDataList.Add(new GetRBIDataResponse()
                    {
                        RBIDataId      = Convert.ToInt32(rBIDataDetail.RBIDataId),
                        RBIDataName    = rBIDataDetail.RBIDataName,
                        Excel          = rBIDataDetail.Excel,
                        IsActive       = Convert.ToBoolean(rBIDataDetail.IsActive),
                        CreatedBy      = rBIDataDetail.CreatedBy,
                        TotalPageCount = rBIDataDetail.TotalPageCount,
                        TotalRecord    = rBIDataDetail.TotalRecord
                    });
                }

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

                Utility.WriteLog("GetRBIData", getRBIDataRequest, "Error while retrieving rbidata. (RBIDataUserController)", ex.ToString());
            }
            return(Ok(responses));
        }