public async Task <IActionResult> Create([Bind("Item_Number,Name,Year,Theme,Subtheme,Pieces,Minifigures,Image_URL,GBP_MSRP,USD_MSRP,CAD_MSRP,EUR_MSRP,Packaging,Availability")] Lego lego) { if (ModelState.IsValid) { _context.Add(lego); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(lego)); }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,UserName,EmailAdress,Password,Adress,PhoneNumber,country,date_of_birth,Gender")] ClassUser classUser) { if (ModelState.IsValid) { _context.Add(classUser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(classUser)); }
public void FindLegoDb([FromBody] string file) { string content = file; foreach (string line in content.Split("\n").Skip(0)) { var columns = line.Split(","); var Item_Number = columns[0]; var Name = columns[1]; var Year = columns[2]; var Theme = columns[3]; var Subtheme = columns[4]; var Pieces = columns[5]; var Minifigures = columns[6]; var Image_URL = columns[7]; var GBP_MSRP = columns[8]; var USD_MSRP = columns[9]; var CAD_MSRP = columns[10]; var EUR_MSRP = columns[11]; var Packaging = columns[12]; var Availability = columns[13]; Lego lego = new Lego { Item_Number = Item_Number, Name = Name, Year = Year, Theme = Theme, Subtheme = Subtheme, Pieces = Pieces, Minifigures = Minifigures, Image_URL = Image_URL, GBP_MSRP = GBP_MSRP, USD_MSRP = USD_MSRP, CAD_MSRP = CAD_MSRP, EUR_MSRP = EUR_MSRP, Packaging = Packaging, Availability = Availability }; _context.Add(lego); _context.SaveChanges(); } }
public void addPurchase(string _id, string _productName, int _amount) { var item = _context.Datas.FirstOrDefault(d => d.productID == _id); if (item == null) { item = new ProductData() { productID = _id, productName = _productName, purchases = _amount, shoppingcart = 0, wishlist = 0 }; _context.Add(item); _context.SaveChanges(); } else { item.purchases = item.purchases + _amount; _context.SaveChanges(); } Console.WriteLine("adding" + _amount + "to" + _productName); }