コード例 #1
0
 public ActionResult ZapiszDetaleNotatki(EdytujNotatkeViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             NotatkaRepozytorium notatkaRepozytorium = new NotatkaRepozytorium();
             Notatka             notatka             = null;
             if (model.Id.HasValue)
             {
                 notatka = notatkaRepozytorium.Pobierz(model.Id.Value);
             }
             else
             {
                 notatka = new Notatka();
             }
             notatka.Temat        = model.Temat;
             notatka.Tresc        = model.Tresc;
             notatka.UzytkownikId = ((Uzytkownik)Session["uzytkownik"]).Id;
             notatka.DataDodania  = DateTime.Now;
             long?rezultatZapisu = notatkaRepozytorium.Zapisz(notatka);
             if (rezultatZapisu != null)
             {
                 return(RedirectToAction("ListaNotatek"));
             }
             else
             {
                 return(View("Error"));
             }
         }
         else
         {
             return(View("DetaleNotatki", model));
         }
     }
     catch (Exception ex)
     {
         LogHelper.Log.Error(ex);
         return(View("Error"));
     }
 }
コード例 #2
0
 public ActionResult DetaleNotatki(long?id)
 {
     try
     {
         EdytujNotatkeViewModel model = new EdytujNotatkeViewModel();
         NotatkaRepozytorium    notatkaRepozytorium = new NotatkaRepozytorium();
         if (id.HasValue == true)
         {
             Notatka pobranaNotatka = notatkaRepozytorium.Pobierz(id.Value);
             model.Id          = pobranaNotatka.Id;
             model.DataDodania = pobranaNotatka.DataDodania;
             model.Temat       = pobranaNotatka.Temat;
             model.Tresc       = pobranaNotatka.Tresc;
         }
         return(View("DetaleNotatki", model));
     }
     catch (Exception ex)
     {
         LogHelper.Log.Error(ex);
         return(View("Error"));
     }
 }