示例#1
0
        public ActionResult Create(Salong salong)
        {
            using (var Klient = new HttpClient())
            {
                try
                {
                    Klient.BaseAddress = new Uri("https://localhost:44379/film");
                    var SkickaUppgift = Klient.PostAsJsonAsync <Salong>("Salong", salong);
                    SkickaUppgift.Wait();

                    var SkickatResultat = SkickaUppgift.Result;

                    if (SkickatResultat.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index"));
                    }
                    ModelState.AddModelError(string.Empty, "Server is currently down please try later, please check with admin");
                }
                catch (DivideByZeroException ex)
                {
                    Logger logger = LogManager.GetLogger("fileLogger");
                    logger.Error("ops!", ex);
                }
            }
            return(View(salong));
        }
示例#2
0
        public ActionResult Edit(int id)
        {
            Salong salong = null;

            using (var Klient = new HttpClient())
            {
                try
                {
                    Klient.BaseAddress = new Uri("https://localhost:44379/film");
                    var SvarUppgift = Klient.GetAsync("Salong/" + id.ToString());
                    SvarUppgift.Wait();
                    var Resultat = SvarUppgift.Result;

                    if (Resultat.IsSuccessStatusCode)
                    {
                        var LasUppgift = Resultat.Content.ReadAsAsync <Salong>();
                        LasUppgift.Wait();
                        salong = LasUppgift.Result;
                    }
                }
                catch (DivideByZeroException ex)
                {
                    Logger logger = LogManager.GetLogger("fileLogger");
                    logger.Error("ops!", ex);
                }
            }
            return(View(salong));
        }
示例#3
0
        public ActionResult Edit(Salong salong)
        {
            using (var Klient = new HttpClient())
            {
                try
                {
                    Klient.BaseAddress = new Uri("https://localhost:44379/Film");
                    var AndraUppgift = Klient.PutAsJsonAsync <Salong>("salong", salong);
                    AndraUppgift.Wait();

                    var Resultat = AndraUppgift.Result;
                    if (Resultat.IsSuccessStatusCode)
                    {
                        return(View(salong));
                    }
                }
                catch (DivideByZeroException ex)
                {
                    Logger logger = LogManager.GetLogger("fileLogger");
                    logger.Error("ops!", ex);
                }
                return(RedirectToAction("Index"));
            }
        }