public bool AddToBasket(Model.APIModel.Purchase.Basket item) { if (item.BasketID == 0) { return(_basketService.Post(item).Type == Model.Enum.Response.DataResponseType.SUCCESS); } else { return(_basketService.Put(item, item.BasketID.ToString()).Type == Model.Enum.Response.DataResponseType.SUCCESS); } }
public DataResponse UpdateQuantity(int id, int value) { var item = _basketService.Get(id.ToString()); var result = _basketService.Put(new Model.APIModel.Purchase.Basket { BasketID = id, Quantity = value, ProductID = item.ProductID, BasketGUID = item.BasketGUID }, id.ToString()); return(new DataResponse { Type = result.Type }); }
public DataResponse Process(DeliveryPageModel model) { var deliveryOptionExists = _basketDeliverySAL.Search(new List <SearchParameter> { new SearchParameter { Name = "CustomerID", Value = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name) } }); var deliveryOptionPrice = _deliveryOptionSAL.Get(model.DeliverySelection.ToString()).Price; if (!deliveryOptionExists.Any()) { _basketDeliverySAL.Post(new BasketDelivery { DeliveryOptionID = model.DeliverySelection, CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), Value = deliveryOptionPrice }); } else { _basketDeliverySAL.Put(new BasketDelivery { DeliveryOptionID = model.DeliverySelection, CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), Value = deliveryOptionPrice }, deliveryOptionExists.FirstOrDefault().CustomerID.ToString()); } var addressExists = _deliveryAddressService.Get(_httpContextAccessor.HttpContext.User.Identity.Name); if (model.UserInvoiceAddress) { if (addressExists == null) { _deliveryAddressService.Post(new Model.APIModel.Customer.DeliveryAddress { CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), Address1 = model.InvoiceAddress1, Address2 = model.InvoiceAddress2, Address3 = model.InvoiceAddress3, Address4 = model.InvoiceAddress4, Address5 = "", Postcode = model.Postcode }); } else { _deliveryAddressService.Put(new Model.APIModel.Customer.DeliveryAddress { CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), Address1 = model.InvoiceAddress1, Address2 = model.InvoiceAddress2, Address3 = model.InvoiceAddress3, Address4 = model.InvoiceAddress4, Address5 = "", Postcode = model.Postcode }, _httpContextAccessor.HttpContext.User.Identity.Name); } } if (model.NewAddress) { if (addressExists == null) { _deliveryAddressService.Post(new Model.APIModel.Customer.DeliveryAddress { CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), Address1 = model.DeliveryAddress1, Address2 = model.DeliveryAddress2, Address3 = model.DeliveryAddress3, Address4 = model.DeliveryAddress4, Address5 = "", Postcode = model.DeliveryPostcode }); } else { _deliveryAddressService.Put(new Model.APIModel.Customer.DeliveryAddress { CustomerID = Int32.Parse(_httpContextAccessor.HttpContext.User.Identity.Name), Address1 = model.DeliveryAddress1, Address2 = model.DeliveryAddress2, Address3 = model.DeliveryAddress3, Address4 = model.DeliveryAddress4, Address5 = "", Postcode = model.DeliveryPostcode }, _httpContextAccessor.HttpContext.User.Identity.Name); } } return(new DataResponse { Type = Model.Enum.Response.DataResponseType.SUCCESS, Details = "" }); }