示例#1
0
        public void UpdateProduct(Products _Product, MobileProperties Mobile, LaptopProperties Laptop)
        {
            Products prod = _Context.Products.Where(x => x.ProductId == _Product.ProductId).SingleOrDefault();

            prod.BrandId            = _Product.BrandId;
            prod.CategoryId         = _Product.CategoryId;
            prod.ProductName        = _Product.ProductName;
            prod.ProductDescription = _Product.ProductDescription;
            prod.ProductPrice       = _Product.ProductPrice;
            prod.ProductQuantity    = _Product.ProductQuantity;
            prod.Discount           = _Product.Discount;
            prod.VendorName         = _Product.VendorName;
            prod.ProductColor       = _Product.ProductColor;
            prod.ProductRate        = _Product.ProductRate;
            prod.IsOffer            = _Product.IsOffer;
            _Context.SaveChanges();
            if (Mobile != null)
            {
                UpdateMobile(Mobile, _Product.ProductId);
            }
            if (Laptop != null)
            {
                UpdateLaptop(Laptop, _Product.ProductId);
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ScreenSize,ScreenType,Ram,CameraPropertry,Battery,ModeNo,FingerPrint,WaterResist,Sim,OperatingSystem,Storage,ExtraProperty")] MobileProperties mobileProperties)
        {
            if (id != mobileProperties.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mobileProperties);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MobilePropertiesExists(mobileProperties.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", mobileProperties.ProductId);
            return(View(mobileProperties));
        }
        public async Task <IActionResult> Create([Bind("ProductId,ScreenSize,ScreenType,Ram,CameraPropertry,Battery,ModeNo,FingerPrint,WaterResist,Sim,OperatingSystem,Storage,ExtraProperty")] MobileProperties mobileProperties)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mobileProperties);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", mobileProperties.ProductId);
            return(View(mobileProperties));
        }
示例#4
0
 public void AddProduct(Products _Product, MobileProperties Mobile, LaptopProperties Laptop)
 {
     _Product.ProductId = (_Context.Products.Select(x => x.ProductId).Max() + 1);
     _Context.Products.Add(_Product);
     _Context.SaveChanges();
     if (Mobile != null)
     {
         Mobile.ProductId = _Product.ProductId;
         _Context.MobileProperties.Add(Mobile);
         _Context.SaveChanges();
     }
     if (Laptop != null)
     {
         Laptop.ProductId = _Product.ProductId;
         _Context.LaptopProperties.Add(Laptop);
         _Context.SaveChanges();
     }
 }
示例#5
0
 void UpdateMobile(MobileProperties Mobile, int prod_Id)
 {
     if (Mobile != null)
     {
         MobileProperties _Mobi = _Context.MobileProperties.Where(x => x.ProductId == prod_Id).SingleOrDefault();
         _Mobi.Ram             = Mobile.Ram;
         _Mobi.Battery         = Mobile.Battery;
         _Mobi.CameraPropertry = Mobile.CameraPropertry;
         _Mobi.ScreenSize      = Mobile.ScreenSize;
         _Mobi.ScreenType      = Mobile.ScreenType;
         _Mobi.Battery         = Mobile.Battery;
         _Mobi.ModeNo          = Mobile.ModeNo;
         _Mobi.FingerPrint     = Mobile.FingerPrint;
         _Mobi.WaterResist     = Mobile.WaterResist;
         _Mobi.Sim             = Mobile.Sim;
         _Mobi.OperatingSystem = Mobile.OperatingSystem;
         _Mobi.Storage         = Mobile.Storage;
         _Mobi.ExtraProperty   = Mobile.ExtraProperty;
         _Context.SaveChanges();
     }
 }