Example #1
0
        public JsonResult AddBillingInfo([FromBody] OrderModel info)
        {
            if (ModelState.IsValid)
            {
                var user = _userManager.GetUserId(User);

                if (user == null)
                {
                    return(Json(info.RedirectUrl = "Login"));
                }

                else
                {
                    var userId = Int32.Parse(user);

                    var billingInfo = new BillingInfo
                    {
                        Adress         = info.Adress,
                        City           = info.City,
                        CountryOrState = info.CountryOrState,
                        Email          = info.Email,
                        PhoneNumber    = info.PhoneNumber
                    };

                    var addBillingInfo = _orders.AddBillingInfo(billingInfo);

                    var updateOrders = _orders.UpdateOrders(info.PaymentMethod, addBillingInfo.Result.Id, userId);

                    return(Json(info.RedirectUrl = "FinaliseOrders"));
                }
            }

            else
            {
                return(Json(info.RedirectUrl = "ShopingCart"));
            }
        }