public IActionResult Post([FromBody] RenewalViewModel renewalViewModel)
        {
            if (_renewal.CheckRenewalPaymentExists(renewalViewModel.NewDate, renewalViewModel.MemberId))
            {
                return(BadRequest("Already Renewed"));//ReasonPhrase
            }
            else
            {
                int cmp    = renewalViewModel.NewDate.CompareTo(renewalViewModel.NextRenwalDate);
                var userId = this.User.FindFirstValue(ClaimTypes.Name);

                if (cmp > 0)
                {
                    var months = _planMaster.GetPlanMonthbyPlanId(renewalViewModel.PlanID);
                    var calculatedNextRenewalDate = renewalViewModel.NewDate.AddMonths(months).AddDays(-1);
                    renewalViewModel.NextRenwalDate = calculatedNextRenewalDate;

                    renewalViewModel.Createdby = Convert.ToInt32(userId);
                    if (_paymentDetails.RenewalPayment(renewalViewModel))
                    {
                        return(Ok("Renewed Successfully"));
                    }
                    else
                    {
                        return(BadRequest("Renewal Failed")); //HttpStatusCode.InternalServerError
                    }
                }

                if (cmp < 0)
                {
                    return(BadRequest("Invalid Date"));
                }
            }
            return(BadRequest("Something went wrong"));
        }
Beispiel #2
0
        public HttpResponseMessage Post([FromBody] RenewalViewModel renewalViewModel)
        {
            if (_renewal.CheckRenewalPaymentExists(renewalViewModel.NewDate, renewalViewModel.MemberId))
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode   = HttpStatusCode.BadRequest,
                    ReasonPhrase = "Already Renewed"
                };
                return(response);
            }
            else
            {
                int cmp    = renewalViewModel.NewDate.CompareTo(renewalViewModel.NextRenwalDate);
                var userId = this.User.FindFirstValue(ClaimTypes.Name);

                if (cmp > 0)
                {
                    var months = _planMaster.GetPlanMonthbyPlanId(renewalViewModel.PlanID);
                    var calculatedNextRenewalDate = renewalViewModel.NewDate.AddMonths(months).AddDays(-1);
                    renewalViewModel.NextRenwalDate = calculatedNextRenewalDate;

                    renewalViewModel.Createdby = Convert.ToInt32(userId);
                    if (_paymentDetails.RenewalPayment(renewalViewModel))
                    {
                        var response = new HttpResponseMessage()
                        {
                            StatusCode   = HttpStatusCode.OK,
                            ReasonPhrase = "Renewed Successfully"
                        };
                        return(response);
                    }
                    else
                    {
                        var response = new HttpResponseMessage()
                        {
                            StatusCode   = HttpStatusCode.InternalServerError,
                            ReasonPhrase = "Renewal Failed"
                        };
                        return(response);
                    }
                }

                if (cmp < 0)
                {
                    var response = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.BadRequest,
                        Content    = new StringContent("Invalid Date")
                    };
                    return(response);
                }
            }

            var responseMessage = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest,
                Content    = new StringContent("Something went wrong")
            };

            return(responseMessage);
        }