Ejemplo n.º 1
0
 public void OnGet(int id)
 {
     if (id.Equals(0))
     {
         _dataPost2 = null;
         _dataInput = null;
     }
     if (_dataInput != null || _dataPost1 != null || _dataPost2 != null)
     {
         if (_dataInput != null)
         {
             Input             = _dataInput;
             Input.AvatarImage = null;
             Input.Image       = _dataPost2.Image;
         }
         else
         {
             if (_dataPost1 != null || _dataPost2 != null)
             {
                 if (_dataPost2 != null)
                 {
                     _dataPost1 = _dataPost2;
                 }
                 Input = new InputModel
                 {
                     Titulo        = _dataPost1.Titulo,
                     Contenido     = _dataPost1.Contenido,
                     Image         = _dataPost1.Image,
                     Categoria     = _dataPost1.Categoria,
                     FechaCreacion = DateTime.Now,
                 };
                 if (_dataInput != null)
                 {
                     Input.ErrorMessage = _dataInput.ErrorMessage;
                 }
             }
         }
     }
     else
     {
         Input = new InputModel
         {
         };
     }
     if (_dataPost2 == null)
     {
         _dataPost2 = _dataPost1;
     }
     _dataPost1 = null;
 }
Ejemplo n.º 2
0
 public async Task <IActionResult> OnPost(String dataPost)
 {
     if (dataPost == null)
     {
         if (_dataPost2 == null)
         {
             if (await SaveAsync())
             {
                 _dataPost2 = null;
                 _dataPost1 = null;
                 _dataInput = null;
                 return(Redirect("/Posts/Posts?area=Posts"));
             }
             else
             {
                 return(Redirect("/Posts/Publish"));
             }
         }
         else
         {
             if (await UpdateAsync())
             {
                 var url = $"/Posts/Input/Read?id={_dataPost2.ID}";
                 _dataPost2 = null;
                 _dataPost1 = null;
                 _dataInput = null;
                 return(Redirect(url));
             }
             else
             {
                 return(Redirect("/Posts/Publish"));
             }
         }
     }
     else
     {
         _dataPost1 = JsonConvert.DeserializeObject <InputModelPosts>(dataPost);
         return(Redirect("/Posts/Publish?id=1"));
     }
 }