コード例 #1
0
        public async Task <IActionResult> EditConfirmed(Boutiq stalk)

        {
            DateTime localDate = DateTime.Now;
            Boutiq   botiq     = new Boutiq
            {
                Id = stalk.Id,

                Type        = stalk.Type,
                Description = stalk.Description,
                Cost        = stalk.Cost,
                DateOfEntry = stalk.DateOfEntry,
                itemImage   = stalk.itemImage,
                status      = stalk.status,
                SalePrice   = stalk.SalePrice,
                DateOfSale  = stalk.DateOfSale
            };


            dbContext.Update(botiq);

            await dbContext.SaveChangesAsync();


            return(RedirectToAction(nameof(GetCurrentStalk)));
        }
コード例 #2
0
        public async Task <IActionResult> New(BoutiqViewModel model)
        {
            DateTime localDat = DateTime.Now;

            totalValue.Add(model.SalePrice);

            BoutiqWorths  = totalValue.Sum();
            ViewBag.Title = "Put your page title here";

            var localDate = localDat.ToString("dd-MMM-yyyy hh:mm:ss");

            if (ModelState.IsValid)
            {
                string   uniqueFileName = UploadedFile(model);
                string   iDate          = model.DateOfSale;
                DateTime oDate          = Convert.ToDateTime(iDate);
                Boutiq   botiq          = new Boutiq
                {
                    Type        = model.Type,
                    Description = model.Description,
                    Cost        = model.Cost,
                    itemImage   = uniqueFileName,
                    status      = model.status,
                    DateOfEntry = localDate,
                    SalePrice   = model.SalePrice,
                    DateOfSale  = oDate,
                    BoutiqWorth = BoutiqWorths
                };
                dbContext.Add(botiq);
                await dbContext.SaveChangesAsync();

                if (botiq.status == "deposited")
                {
                    return(RedirectToAction(nameof(GetAllDeposited)));
                }

                else if (botiq.status == "sold")
                {
                    return(RedirectToAction(nameof(GetSoldStalk)));
                }
                return(RedirectToAction(nameof(GetCurrentStalk)));
            }
            return(View());
        }