Пример #1
0
        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);
        }
Пример #2
0
 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;
     }
 }
Пример #3
0
        public ActionResult Edit(int id, GiftsDto gift)
        {
            try
            {
                GiftsLoader.Save(gift);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }