Ejemplo n.º 1
0
        public IEnumerable <ActName> GetActName(ActName actName)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var actNames = dataContext.ActNameGet(actName.ActId, Utility.TrimString(actName.SearchText), actName.IsActive, actName.PageNumber, actName.PageSize, actName.IsPagingRequired, Utility.TrimString(actName.OrderBy), Utility.TrimString(actName.OrderByDirection), totalPageCount, totalRecord).ToList();

                var actNameList = new List <ActName>();
                foreach (var actNameDetail in actNames)
                {
                    actNameList.Add(new ActName()
                    {
                        ActId          = actNameDetail.ActID,
                        LongTitle      = actNameDetail.LongTitle,
                        ActPDF         = actNameDetail.ActPDF,
                        IsActive       = actNameDetail.IsActive,
                        TotalPageCount = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord    = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(actNameList);
            }
        }
        public IHttpActionResult UpdateActName(UpdateActNameRequest updateActNameRequest)
        {
            var responses = new Responses();

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

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

                var actName = new ActName()
                {
                    ActId      = updateActNameRequest.ActId,
                    LongTitle  = updateActNameRequest.LongTitle,
                    ActPDF     = updateActNameRequest.ActPDF,
                    ModifiedBy = Utility.UserId
                };
                int result = iActName.UpdateActName(actName);

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

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

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

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

                Utility.WriteLog("UpdateActName", updateActNameRequest, "Error while updating actname. (ActNameAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Ejemplo n.º 3
0
        public int DeleteActName(ActName actName)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.ActNameDelete(actName.ActId, actName.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
Ejemplo n.º 4
0
        public int UpdateActName(ActName actName)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.ActNameUpdate(actName.ActId, Utility.TrimString(actName.LongTitle), Utility.TrimString(actName.ActPDF), actName.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult AddActName(AddActNameRequest addActNameRequest)
        {
            var responses = new Responses();

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

                var actName = new ActName()
                {
                    LongTitle = addActNameRequest.LongTitle,
                    ActPDF    = addActNameRequest.ActPDF
                };
                int result = iActName.AddActName(actName);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "ActName added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "ActName alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding actname.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding actname.";

                Utility.WriteLog("AddActName", addActNameRequest, "Error while adding actname. (ActNameAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetActName([FromUri] GetActNameRequest getActNameRequest)
        {
            var responses = new Responses();

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

                if (getActNameRequest == null)
                {
                    getActNameRequest = new GetActNameRequest();
                }

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

                var actName = new ActName()
                {
                    ActId            = getActNameRequest.ActId,
                    SearchText       = getActNameRequest.SearchText,
                    IsActive         = getActNameRequest.IsActive,
                    PageNumber       = getActNameRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getActNameRequest.PageSize),
                    IsPagingRequired = (getActNameRequest.PageNumber != null) ? true : false,
                    OrderBy          = getActNameRequest.OrderBy,
                    OrderByDirection = getActNameRequest.OrderByDirection
                };
                var actNames = iActName.GetActName(actName);

                var actNameList = new List <GetActNameResponse>();
                foreach (var actNameDetail in actNames)
                {
                    actNameList.Add(new GetActNameResponse()
                    {
                        ActId          = Convert.ToInt32(actNameDetail.ActId),
                        LongTitle      = actNameDetail.LongTitle,
                        ActPDF         = actNameDetail.ActPDF,
                        IsActive       = Convert.ToBoolean(actNameDetail.IsActive),
                        CreatedBy      = actNameDetail.CreatedBy,
                        TotalPageCount = actNameDetail.TotalPageCount,
                        TotalRecord    = actNameDetail.TotalRecord
                    });
                }

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

                Utility.WriteLog("GetActName", getActNameRequest, "Error while retrieving actname. (ActNameAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }