示例#1
0
        public bool Create(Venta venta, DetalleVenta detalleVenta)
        {
            try
            {
                if (venta.ventaId == 0)
                {
                    _contextDatabase.Venta.Add(venta);
                }
                else
                {
                    _contextDatabase.Entry(venta).State = EntityState.Modified;
                }

                foreach (var item in venta.DetalleVenta)
                {
                    if (item.DetalleVentaId == 0)
                    {
                        _contextDatabase.DetalleVenta.Add(item);
                    }
                    else
                    {
                        _contextDatabase.Entry(item).State = EntityState.Modified;
                    }
                }

                foreach (var item in venta.DetalleVenta.SelectMany(sub => sub.SubDetalleVenta))
                {
                    if (item.DetalleVentaId == 0)
                    {
                        _contextDatabase.SubDetalleVenta.Add(item);
                    }
                    else
                    {
                        _contextDatabase.Entry(item).State = EntityState.Modified;
                    }
                }
                _contextDatabase.SaveChanges();
                return(true);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
 public ActionResult Edit([Bind(Include = "IfnsCode,IfnsName,Order")] Ifns ifns)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ifns).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ifns));
 }
 public ActionResult Edit([Bind(Include = "Id,IfnsCode,CameraImgLink,CameraImgFile,CameraDisable,CameraDisableDescription,CameraAuthUser,CameraAuthPassword")] General general)
 {
     if (ModelState.IsValid)
     {
         db.Entry(general).State = EntityState.Modified;
         db.SaveChanges();
         return(this.Index(general.IfnsCode));
         //return RedirectToAction("Index");
     }
     ViewBag.IfnsCode = new SelectList(db.TIfns, "IfnsCode", "IfnsName", general.IfnsCode);
     return(View(general));
 }
示例#4
0
        public ActionResult Edit([Bind(Include = "Id,CameraDisable,CameraDisableDescription")] General general)
        {
            //if (ModelState.IsValid)
            if (general != null)
            {
                General modelGeneral = db.TGeneral.Find(general.Id);
                modelGeneral.CameraDisable            = general.CameraDisable;
                modelGeneral.CameraDisableDescription = general.CameraDisableDescription;

                db.TGeneral.Attach(modelGeneral);
                db.Entry(modelGeneral).Property(x => x.CameraDisable).IsModified            = true;
                db.Entry(modelGeneral).Property(x => x.CameraDisableDescription).IsModified = true;
                db.SaveChanges();
                return(this.Index(modelGeneral.IfnsCode));
            }
            ViewBag.IfnsCode = new SelectList(db.TIfns, "IfnsCode", "IfnsName", general.IfnsCode);
            if (general != null)
            {
                ViewBag.g = general;
            }
            return(View(general));
        }
        public ActionResult Setting(ICollection <Configuration> listConfiguration)
        {
            if (listConfiguration == null || listConfiguration.Count == 0)
            {
                throw new HttpException(400, "Некорректный запрос");
            }

            string errors = "";

            foreach (Configuration configuration in listConfiguration)
            {
                if (db.Entry(configuration).GetValidationResult().IsValid)
                {
                    db.Entry(configuration).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    foreach (var s in db.Entry(configuration).GetValidationResult().ValidationErrors)
                    {
                        errors += s.ErrorMessage + " Id: " + configuration.Id + " <br />";
                    }
                }
            }

            if (errors == "")
            {
                ViewBag.SaveState = "OK";
                ViewBag.StateText = "Данные успешно сохранены!";
            }
            else
            {
                ViewBag.SaveState = "Erorr";
                ViewBag.StateText = errors;
            }

            return(this.Setting());
        }
示例#6
0
 public void Update(Shipping item)
 {
     context.Entry(item).State = System.Data.Entity.EntityState.Modified;
 }
示例#7
0
 public void Update(User item)
 {
     context.Entry(item).State = EntityState.Modified;
 }
示例#8
0
 public void Update(Category item)
 {
     context.Entry(item).State = System.Data.Entity.EntityState.Modified;
 }
 public void Update(NutritionBlog item)
 {
     context.Entry(item).State = System.Data.Entity.EntityState.Modified;
 }
 public void Update(SportSupplement item)
 {
     context.Entry(item).State = System.Data.Entity.EntityState.Modified;
 }