Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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)));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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);
        }