Exemple #1
0
 public int SaveDocStatus(h_docStatuses element, bool withSave = true)
 {
     if (element.id == 0)
     {
         db.h_docStatuses.Add(element);
         if (withSave)
         {
             Save();
         }
     }
     else
     {
         db.Entry(element).State = EntityState.Modified;
         if (withSave)
         {
             Save();
         }
     }
     return(element.id);
 }
        public h_docStatuses CreateDocStatus(Dictionary <string, string> parameters, aspnet_Users user, out string msg)
        {
            msg = "";
            h_docStatuses res;

            try
            {
                if (!_canAccessToItem(user))
                {
                    msg = "Нет прав создавать элемента";
                    res = null;
                }
                else
                {
                    res = new h_docStatuses();
                    foreach (var key in parameters.Keys)
                    {
                        switch (key)
                        {
                        case "name": res.name = parameters[key];
                            break;

                        case "code": res.code = parameters[key];
                            break;
                        }
                    }
                    _db.SaveDocStatus(res);
                }
            }
            catch (Exception e)
            {
                _debug(e, new { }, "Ошибка возникла при создании элемента");
                res = null;
            }
            return(res);
        }