Beispiel #1
0
 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);
     }
 }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            StrSl Str = strslDAO.getStrSl(id);

            if (!ViewDataSelectList(Str.GroupDog.Id))
            {
                return(RedirectToAction("MyObject"));
            }
            return(View(strslDAO.getStrSl(id)));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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"));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 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)));
     }
 }
Beispiel #7
0
 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));
     }
 }
Beispiel #8
0
        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);
        }