Ejemplo n.º 1
0
 public string AddDeliveryAddress(AddDeliveryAddressModel model)
 {
     try
     {
         using (dbContext)
         {
             var deliveryAddress = new Delivery
             {
                 Id                = model.Id,
                 City              = model.City,
                 Complex           = model.Complex,
                 Fullnames         = model.Fullnames,
                 isResidential     = model.isResidential,
                 PostalCode        = model.PostalCode,
                 Province          = model.Province,
                 RecipientMobileNo = model.RecipientMobileNo,
                 StreetAddress     = model.StreetAddress,
                 Suburb            = model.Suburb
             };
             dbContext.Add(deliveryAddress);
             dbContext.SaveChanges();
             return("Succesfully Added !");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message.ToString());
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddDeliveryAddress(AddDeliveryAddressModel model)
        {
            AddDeliveryAddressModel receivedDeliveryAddress = new AddDeliveryAddressModel();

            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
                using (var response = await httpClient.PostAsync("https://localhost:44374/api/Delivery/PostDelivery", content))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    receivedDeliveryAddress = JsonConvert.DeserializeObject <AddDeliveryAddressModel>(apiResponse);
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 3
0
 public async Task <ActionResult <AddDeliveryAddressModel> > PostDelivery(AddDeliveryAddressModel model)
 {
     _context.AddDeliveryAddress(model);
     return(CreatedAtAction("GetAllDeliveries", new { id = model.Id }, model));
 }