Beispiel #1
0
        public motskin_contractors Create(Dictionary <string, string> parameters, aspnet_Users user, out string msg)
        {
            motskin_contractors res;

            msg = "";
            try
            {
                if (!_IsCanUserChange(user))
                {
                    msg = "Нет прав для данной операции";
                    return(null);
                }

                res = new motskin_contractors();
                _fillContractor(res, parameters);
                _db.SaveContractor(res);  // сохраняем в бд
            }
            catch (Exception ex)
            {
                _debug(ex, new { userName = user.UserName });
                res = null;
                msg = "Сбой при выполнении операции";
            }

            return(res);
        }
Beispiel #2
0
        public static bool DeleteContractor(int id)
        {
            motskin_contractors element = _contractors.FirstOrDefault(p => p.id == id);

            if (element != null)
            {
                _contractors.Remove(element);
                return(true);
            }
            return(false);
        }
Beispiel #3
0
 private void _fillContractor(motskin_contractors item, Dictionary <string, string> parameters)
 {
     foreach (var key in parameters.Keys)
     {
         switch (key)
         {
         case "name":
             item.name = parameters[key];
             break;
         }
     }
 }
Beispiel #4
0
 public static int SaveContractor(motskin_contractors element, bool withSave = true)
 {
     if (element.id == 0)
     {
         element.id = _contractors.Count + 1;
         _contractors.Add(element);
     }
     else
     {
         int pos = _contractors.IndexOf(_contractors.FirstOrDefault(p => p.id == element.id));
         if (pos >= 0)
         {
             _contractors[pos] = element;
         }
     }
     return(_contractors.Count);
 }
Beispiel #5
0
        public int SaveContractor(motskin_contractors element, bool withSave = true)
        {
#if !PSEUDO
            if (element.id == 0)
            {
                db.motskin_contractors.Add(element);
                if (withSave)
                {
                    Save();
                }
            }
            else
            {
                db.Entry(element).State = EntityState.Modified;
                if (withSave)
                {
                    Save();
                }
            }
            return(element.id);
#else
            return(PseudoData.SaveContractor(element));
#endif
        }