示例#1
0
 public IActionResult Andra(VMSida vmSida, string btn)
 {
     if (btn == "LaddaUppFil" && vmSida.Fil != null)
     {
         FilService service = new FilService();
         if (!service.ValideraFil(vmSida.Fil))
         {
             ModelState.Clear();
             ModelState.TryAddModelError("Fil", "Fel fil");
             return(View());
         }
         var fil = service.SparaFil(vmSida.Fil);
         _context.SparaBild(fil);
         ModelState.Clear();
         vmSida.Innehall += service.GetHtmlString(fil);
         return(View(vmSida));
     }
     if (ModelState.IsValid)
     {
         SidaTransform st   = new SidaTransform();
         var           sida = st.Transform(vmSida);
         _context.Andra(sida);
         return(RedirectToRoute("sidor", new { Id = sida.Id }));
     }
     else
     {
         return(View());
     }
 }
示例#2
0
        public IActionResult Andra(int id)
        {
            var sida = _context.Get(id);

            if (sida != null)
            {
                SidaTransform st     = new SidaTransform();
                var           vmSida = st.Transform(sida);
                return(View(vmSida));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }