Beispiel #1
0
 public ActionResult Edit(int id, EditContinentDto model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ContinentDto continent = new ContinentDto();
             using (var repository = new WebApiClientRepository <ContinentDto>())
             {
                 var response = repository.Put(model, "Continent");
                 if (response != null)
                 {
                     if (response.data != null)
                     {
                         continent = JsonConvert.DeserializeObject <ContinentDto>(response.data.ToString());
                         TempData["message_data"] = response.message;
                         return(RedirectToAction(nameof(Index)));
                     }
                     else
                     {
                         TempData["message_data"] = response.message;
                         return(RedirectToAction(nameof(Index)));
                     }
                 }
             }
         }
         // TODO: Add insert logic here
         TempData["message_data"] = "Problem on Athlete adding";
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #2
0
        // GET: Continent/Edit/5
        public ActionResult Edit(int id)
        {
            EditContinentDto continent = new EditContinentDto();

            using (var repository = new WebApiClientRepository <EditContinentDto>())
            {
                var payload = repository.GetById(id, "Continent/");
                if (payload != null)
                {
                    if (payload.data != null)
                    {
                        continent = JsonConvert.DeserializeObject <EditContinentDto>(payload.data.ToString());
                    }
                }
            }
            return(View(continent));
        }