Esempio n. 1
0
 private bool BoxCreate(Smt_box item)
 {
     return(CheckIsNotProcessingApply(db.SmtBoxes, x =>
     {
         if (x.FirstOrDefault(y => y.Code == item.Code && y.ElementId == item.ElementId) == null)
         {
             x.Add(item);
             return true;
         }
         else
         {
             return false;
         }
     }));
 }
Esempio n. 2
0
        public bool Update(Smt_box item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("Item cannot be null");
            }

            if (IsNotProcessing())
            {
                var tmp = db.SmtBoxes.FirstOrDefault(x => x.ElementId == item.ElementId && x.Code == item.Code);
                if (tmp != null)
                {
                    tmp.CreationDate = item.CreationDate;
                    tmp.ElementId    = item.ElementId;
                    tmp.Spent        = item.Spent;
                    tmp.InFeeder     = item.InFeeder;
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 3
0
        public ActionResult CreateBox(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            var tmp = u.Get(delegate(Element x) { return(x.Code == id); });

            if (tmp != null)
            {
                var box = new Smt_box(tmp);
                box.ElementId = tmp.Code;
                tmp.Boxes.Add(box);
                if (u.Create(box))
                {
                    u.Save();
                    return(RedirectToAction("Index"));
                }
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
 public bool Delete(Smt_box Item)
 {
     return(Delete(db.SmtBoxes, Item));
 }
Esempio n. 5
0
 public bool Create(Smt_box item)
 {
     return(BoxCreate(item));
 }