public static GiftsViewModel MapGift(GiftsDto gift) { GiftsViewModel giftViewModel = new GiftsViewModel(); giftViewModel.Id = gift.Id; giftViewModel.Name = gift.Name; giftViewModel.Cost = gift.Cost; giftViewModel.Orders = new List <OrderViewModel>(); return(giftViewModel); }
public static void Save(GiftsDto gift) { if (gift.Id == 0) { HttpResponseMessage response = GlobalVariables.WebApiClient.PostAsJsonAsync("Gift", gift).Result; } else { HttpResponseMessage response = GlobalVariables.WebApiClient.PutAsJsonAsync("Gift/" + gift.Id, gift).Result; } }
public ActionResult Edit(int id, GiftsDto gift) { try { GiftsLoader.Save(gift); return(RedirectToAction("Index")); } catch { return(View()); } }