public ActionResult AddCategoriePost(Categorie categorie) { InitCategories(); if (categorie.Id == 0) { categorie.Save(); } else { categorie.Update(); } return(RedirectToAction("Index")); }
public Categorie GetCategorieDefault(Session currentSession = null) { try { XPQuery <Categorie> categorie = null; if (currentSession != null) { categorie = currentSession.Query <Categorie>(); } else { categorie = session.Query <Categorie>(); } var obj = categorie.Where(c => c.Name.Contains("Neznana")).FirstOrDefault(); if (obj == null) { obj = new Categorie(session); obj.Name = "Neznana kategorija"; obj.Code = "NEZNANO"; obj.Notes = "Avtomatsko generirana privzeta kategorija iz strani ETT aplikacije!"; obj.tsInsert = DateTime.Now; obj.tsInsertUserID = 0; obj.tsUpdate = DateTime.Now; obj.tsUpdateUserID = 0; obj.Save(); } return(obj); } catch (Exception ex) { string error = ""; CommonMethods.getError(ex, ref error); throw new Exception(CommonMethods.ConcatenateErrorIN_DB(DB_Exception.res_10, error, CommonMethods.GetCurrentMethodName())); } }
public int SaveCategorie(Categorie model, int userID = 0) { try { model.tsUpdate = DateTime.Now; model.tsUpdateUserID = userID; if (model.CategorieID == 0) { model.tsInsert = DateTime.Now; model.tsInsertUserID = userID; } model.Save(); return(model.CategorieID); } catch (Exception ex) { string error = ""; CommonMethods.getError(ex, ref error); throw new Exception(CommonMethods.ConcatenateErrorIN_DB(DB_Exception.res_14, error, CommonMethods.GetCurrentMethodName())); } }
//Sauvegarde categorie public IActionResult SubmitFormCateogrie(Categorie categorie) { string message, typeMessage; if (categorie.Titre != null) { if (categorie.Save()) { message = "La catégorie a bien été ajoutée"; typeMessage = "success"; } else { message = "Erreur d'insertion dans la base de données"; typeMessage = "error"; } } else { message = "Merci de remplir le champ titre"; typeMessage = "danger"; } return(RedirectToAction("FormCategorie", new { message = message, typeMessage = typeMessage })); }