public void CreateStrSl(StrSl model) { try { using (var ctx = new Entities()) { string query = "INSERT INTO StrSl (IDKl, IDAg, IDDogv, Date, Described, IDGroup) VALUES(@P0, @P1, @P2, @P3, @P4, @P5)"; List <object> parameterList = new List <object> { model.IDKl, model.IDAg, model.IDDogv, model.Date, model.Described, model.IDGroup }; object[] parameters = parameterList.ToArray(); int result = ctx.Database.ExecuteSqlCommand(query, parameters); Logger.Log.Info("Данные успешно добавлены в StrSl"); } } catch (Exception ex) { Logger.Log.Error("Ошибка: ", ex); } }
public ActionResult Edit(int id) { StrSl Str = strslDAO.getStrSl(id); if (!ViewDataSelectList(Str.GroupDog.Id)) { return(RedirectToAction("MyObject")); } return(View(strslDAO.getStrSl(id))); }
public ActionResult Create(string id) { string userId = User.Identity.GetUserId(); StrSl strsl = new StrSl(); using (Entities ent = new Entities()) { strsl.IDKl = userId; } return(View(strsl)); }
public ActionResult Create(StrSl model) { string userId = User.Identity.GetUserId(); model.IDKl = userId; try { strslDAO.CreateStrSl(model); return(RedirectToAction("MyObject")); } catch (Exception ex) { Logger.Log.Error("Ошибка: ", ex); } return(RedirectToAction("Create")); }
public bool deleteStrSl(int Id) { StrSl originalStrSl = getStrSl(Id); try { _entities.StrSl.Remove(originalStrSl); _entities.SaveChanges(); } catch (Exception ex) { Logger.Log.Error("Ошибка: ", ex); return(false); } return(true); }
public ActionResult Delete(int id, StrSl Str) { try { if (strslDAO.deleteStrSl(id)) { return(RedirectToAction("MyObject")); } else { return(View(strslDAO.getStrSl(id))); } } catch (Exception ex) { Logger.Log.Error("Ошибка: ", ex); return(View(strslDAO.getStrSl(id))); } }
public ActionResult Edit(StrSl Str) { ViewDataSelectList(-1); try { if (ModelState.IsValid && strslDAO.updateStrSl(Str)) { return(RedirectToAction("MyObject")); } else { return(View(Str)); } } catch (Exception ex) { Logger.Log.Error("Ошибка: ", ex); return(View(Str)); } }
public bool updateStrSl(StrSl Str) { StrSl originalRecords = getStrSl(Str.Id); try { originalRecords.IDKl = Str.IDKl; originalRecords.IDDogv = Str.IDDogv; originalRecords.Date = Str.Date; originalRecords.Described = Str.Described; originalRecords.IDGroup = Str.IDGroup; _entities.SaveChanges(); } catch (Exception ex) { Logger.Log.Error("Ошибка: ", ex); return(false); } return(true); }