Example #1
0
        public async Task <ActionResult> GoodEdit(EditGoodModel model)
        {
            Good good = await db.Goods.FindAsync(model.GoodId);

            if (good != null)
            {
                good.GoodName     = model.GoodName;
                good.Manufacturer = model.Manufacturer;
                good.Category     = model.Category;
                good.Price        = model.Price;//Convert.ToDecimal(model.Price, CultureInfo.InvariantCulture);
                good.GoodCount    = model.GoodCount;
                good.Photo        = model.Photo;

                db.Entry(good).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Admin"));
            }
            return(PartialView(model));
        }
        public async Task <IActionResult> EditGood(EditGoodModel model)
        {
            Instrument instrument = await GetReadyToAddInstrument(model);

            instrument.Id = model.Id;
            instrument.Image ??= model.ImageSrc;

            var entity = await ctx.FindAsync <Instrument>(instrument.Id);

            if (entity == null)
            {
                throw new InvalidOperationException("null entity at editgood");
            }

            ctx.Entry(entity).CurrentValues.SetValues(instrument);

            await ctx.SaveChangesAsync();

            return(Ok());
        }
Example #3
0
        public async Task <ActionResult> GoodEdit(int id)
        {
            Good good = await db.Goods.FindAsync(id);

            if (good != null)
            {
                EditGoodModel model = new EditGoodModel
                {
                    GoodId       = good.GoodId,
                    GoodName     = good.GoodName,
                    Manufacturer = good.Manufacturer,
                    Category     = good.Category,
                    Price        = good.Price,
                    GoodCount    = good.GoodCount,
                    Photo        = good.Photo
                };
                return(PartialView(model));
            }
            return(RedirectToAction("Index", "Admin"));
        }