Esempio n. 1
0
        public ActionResult Edit

            (int id, SaleEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var companyservice = new CompanyService();

            ViewBag.CompanyID = new SelectList(companyservice.GetCompanies(), "CompanyID", "CompanyName");
            if (model.SaleID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = CreateSaleService();

            if (service.UpdateSale(model))
            {
                TempData["SaveResult"] = "Your sale was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your sale could not be updated.");
            return(View(model));
        }
Esempio n. 2
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            var companyservice = new CompanyService();


            ViewBag.CompanyID = new SelectList(companyservice.GetCompanies(), "CompanyID", "CompanyName");

            var service = CreateSaleService();
            var detail  = service.GetSaleById(id.Value);
            var model   =
                new SaleEdit
            {
                SaleID        = detail.SaleID,
                Address       = detail.Address,
                SalePrice     = detail.SalePrice,
                SquareFootage = detail.SquareFootage,
                Buyer1        = detail.Buyer1,
                Seller1       = detail.Seller1,
            };

            return(View(model));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "SaleID,Customer.CustomerID,Product.ProductID,Quantity,SaleDate")] SaleEdit saleEdit)
 {
     if (ModelState.IsValid)
     {
         serviceSales.UpdateSale(saleEdit.ToSale());
         return(RedirectToAction("Index"));
     }
     return(View(saleEdit));
 }
Esempio n. 4
0
        // UPDATE
        public bool UpdateSale(SaleEdit model)
        {
            var saleEntity = _context.Sales.Find(model.SaleId);

            saleEntity.SaleId       = model.SaleId;
            saleEntity.DayOfTheWeek = model.DayOfTheWeek;
            saleEntity.SalePrice    = model.SalePrice;
            saleEntity.BreweryId    = model.BreweryId;

            return(_context.SaveChanges() == 1);
        }
        // EDIT: Sale/{id}
        public ActionResult Edit(int id)
        {
            var detail = _service.GetSaleById(id);
            var model  =
                new SaleEdit
            {
                SaleId       = detail.SaleId,
                DayOfTheWeek = detail.DayOfTheWeek,
                SalePrice    = detail.SalePrice,
                BreweryId    = detail.BreweryId
            };

            return(View(model));
        }
Esempio n. 6
0
        // GET: SaleViews/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SaleEdit saleEdit = new SaleEdit(serviceSales.GetSale(Convert.ToInt32(id)),
                                             serviceProducts.GetProducts(), serviceCustomers.GetCustomers());

            if (saleEdit == null)
            {
                return(HttpNotFound());
            }
            return(View(saleEdit));
        }
        public bool UpdateSale(SaleEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Sales
                    .Single(e => e.SaleID == model.SaleID && (e.OwnerID == _userId || e.CompanyID == 1));
                entity.Address       = model.Address;
                entity.SalePrice     = model.SalePrice;
                entity.SquareFootage = model.SquareFootage;
                entity.Buyer1        = model.Buyer1;
                entity.Seller1       = model.Seller1;
                entity.CompanyID     = model.CompanyID;
                entity.ModifiedUtc   = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 8
0
        public ActionResult Edit(int id)
        {
            var service = CreateSaleService();
            var detail  = service.GetSaleByID(id);
            var model   =
                new SaleEdit
            {
                SaleID = detail.SaleID,
                //ArtID = detail.ArtID,
                //ClientID = detail.ClientID,
                Title             = detail.Title,
                Location          = detail.Location,
                Price             = detail.Price,
                SellingPrice      = detail.SellingPrice,
                VenderCommission  = detail.VenderCommission,
                DateOfTransaction = detail.DateOfTransaction,
            };

            return(View(model));
        }
Esempio n. 9
0
        public bool UpdateSale(SaleEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Sales
                    .Single(e => e.SaleID == model.SaleID && e.OwnerID == _userId);
                entity.SaleID = model.SaleID;
                //entity.ClientID = model.ClientID;
                entity.Art.Title = model.Title;
                //entity.ArtID = model.ArtID;
                entity.Location = model.Location;
                //entity.Price = model.Price;
                entity.SellingPrice      = model.SellingPrice;
                entity.VenderCommission  = model.VenderCommission;
                entity.DateOfTransaction = model.DateOfTransaction;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, SaleEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.SaleId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            if (_service.UpdateSale(model))
            {
                TempData["SaveResult"] = "Your sale was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your sale could not be updated.");
            return(View(model));
        }
Esempio n. 11
0
        public ActionResult Edit(int id, SaleEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.SaleID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateSaleService();

            if (service.UpdateSale(model))
            {
                TempData["SaveResult"] = "Your Sale Information Was Updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Sale Could Not Be UPDATED.");
            return(View(model));
        }
Esempio n. 12
0
        // GET: SaleViews/Create
        public ActionResult Create()
        {
            SaleEdit saleEdit = new SaleEdit(serviceProducts.GetProducts(), serviceCustomers.GetCustomers());

            return(View(saleEdit));
        }