public async Task <IActionResult> Edit(int id, [Bind("Id,DesignId,SizeId,ColorId,Description,Title,Price")] Shirts shirts) { if (id != shirts.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shirts); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShirtsExists(shirts.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ColorId"] = new SelectList(_context.Color, "Id", "Id", shirts.ColorId); ViewData["DesignId"] = new SelectList(_context.Designs, "Id", "Id", shirts.DesignId); //ViewData["SizeId"] = new SelectList(_context.Size, "Id", "Id", shirts.SizeId); return(View(shirts)); }
public void AddToCart(Shirts shirt) { // Get the matching cart and album instances var cartItem = storeDB.Carts.SingleOrDefault( c => c.CartId == ShoppingCartId && c.ShirtsId == shirt.Id); if (cartItem == null) { // Create a new cart item if no cart item exists cartItem = new Cart { ShirtsId = shirt.Id, CartId = ShoppingCartId, Count = 1, DateCreated = DateTime.Now }; storeDB.Carts.Add(cartItem); } else { // If the item does exist in the cart, // then add one to the quantity cartItem.Count++; } // Save changes storeDB.SaveChanges(); }
public void Assignment1_TestDerivedClassShirts_ReturnTrue() { bool myresult = false; Shirts shirt = new Shirts(92321344, "shirts", "Shirt", 1234); if (shirt.GetType() == typeof(Shirts)) { myresult = true; } Assert.IsTrue(myresult, "My shirt is of type shirt."); }
public async Task <IActionResult> Create(Shirts shirts) { if (ModelState.IsValid) { _context.Add(shirts); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ColorId"] = new SelectList(_context.Color, "Id", "Id", shirts.ColorId); ViewData["DesignId"] = new SelectList(_context.Designs, "Id", "Id", shirts.DesignId); //ViewData["SizeId"] = new SelectList(_context.Size, "Id", "Id", shirts.SizeId); return(View(shirts)); }
public override void Initialize() { base.Initialize(); Urges = new Urges(); AssignableSlots = new AssignableSlots(); StateMachineCategories = new StateMachineCategories(); Personalities = new Personalities(); Faces = new Faces(); Shirts = new Shirts(); Expressions = new Expressions(Root); Thoughts = new Thoughts(Root); Deaths = new Deaths(Root); StatusItemCategories = new StatusItemCategories(Root); Techs = new Techs(Root); Techs.Load(researchTreeFile); TechTreeTitles = new TechTreeTitles(Root); TechTreeTitles.Load(researchTreeFile); TechItems = new TechItems(Root); Accessories = new Accessories(Root); AccessorySlots = new AccessorySlots(Root, null, null, null); ScheduleBlockTypes = new ScheduleBlockTypes(Root); ScheduleGroups = new ScheduleGroups(Root); RoomTypeCategories = new RoomTypeCategories(Root); RoomTypes = new RoomTypes(Root); ArtifactDropRates = new ArtifactDropRates(Root); SpaceDestinationTypes = new SpaceDestinationTypes(Root); Diseases = new Diseases(Root); Sicknesses = new Database.Sicknesses(Root); SkillPerks = new SkillPerks(Root); SkillGroups = new SkillGroups(Root); Skills = new Skills(Root); ColonyAchievements = new ColonyAchievements(Root); MiscStatusItems = new MiscStatusItems(Root); CreatureStatusItems = new CreatureStatusItems(Root); BuildingStatusItems = new BuildingStatusItems(Root); ChoreTypes = new ChoreTypes(Root); Effect effect = new Effect("CenterOfAttention", DUPLICANTS.MODIFIERS.CENTEROFATTENTION.NAME, DUPLICANTS.MODIFIERS.CENTEROFATTENTION.TOOLTIP, 0f, true, true, false, null, 0f, null); effect.Add(new AttributeModifier("StressDelta", -0.008333334f, DUPLICANTS.MODIFIERS.CENTEROFATTENTION.NAME, false, false, true)); effects.Add(effect); CollectResources(Root, ResourceTable); }
public List <Shirts> showShirts() { List <Shirts> shirtList = new List <Shirts>(); Connection(); SqlDataReader reader; //Creating an instance of SqlCommand SqlCommand cmd; //Intialising SqlCommand cmd = new SqlCommand("uspShowAllShirts", conn); cmd.CommandType = CommandType.StoredProcedure; try { conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { Shirts shirt = new Shirts(); shirt.ProductId = reader["ShirtID"].ToString(); shirt.ProductName = reader["ShirtName"].ToString(); shirt.ProductDescription = reader["ShirtDescription"].ToString(); shirt.ProductPricePerUnit = decimal.Parse(reader["ShirtPricePerUnit"].ToString()); shirt.ProductQuantity = int.Parse(reader["ShirtQuantity"].ToString()); shirt.ProductSize = reader["ShirtSize"].ToString(); shirt.ProductColour = reader["ShirtColour"].ToString(); shirt.ShirtImage = (byte[])reader["ShirtImage"]; shirtList.Add(shirt); } } catch (Exception ex) { message = ex.Message; } finally { conn.Close(); } return(shirtList); }
public Wardrobe(String filename) { shirts = new List <ClothingItem>(); pants = new List <ClothingItem>(); shoes = new List <ClothingItem>(); errorText = ""; //Create COM Objects. Create a COM object for everything that is referenced Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(filename); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; int rowCount = xlRange.Rows.Count; int colCount = xlRange.Columns.Count; //iterate over the rows and columns and print to the console as it appears in the file //excel is not zero based!! String name = ""; String type = ""; String color = ""; bool error = false; for (int i = 1; i <= rowCount; i++) { for (int j = 1; j <= colCount; j++) { //new line if (j == 1) { name = xlRange.Cells[i, j].Value2; } else if (j == 2) { type = xlRange.Cells[i, j].Value2; } else if (j == 3) { color = xlRange.Cells[i, j].Value2; } else { //too many columns error = true; } //write the value to the console //if (xlRange.Cells[i, j] != null && xlRange.Cells[i, j].Value2 != null) //Console.Write(xlRange.Cells[i, j].Value2.ToString() + "\t"); } if (error == false) { ClothingItem temp = new ClothingItem(getType(type, i), getColor(color, i), name); if (temp.Category == ClothingCategory.Shirt) { Shirts.Add(temp); } else if (temp.Category == ClothingCategory.Pants) { Pants.Add(temp); } else if (temp.Category == ClothingCategory.Shoes) { Shoes.Add(temp); } } else { throw new InvalidOperationException("Excel file is incorrectly constructed."); } } //cleanup GC.Collect(); GC.WaitForPendingFinalizers(); //rule of thumb for releasing com objects: // never use two dots, all COM objects must be referenced and released individually // ex: [somthing].[something].[something] is bad //release com objects to fully kill excel process from running in the background Marshal.ReleaseComObject(xlRange); Marshal.ReleaseComObject(xlWorksheet); //close and release xlWorkbook.Close(); Marshal.ReleaseComObject(xlWorkbook); //quit and release xlApp.Quit(); Marshal.ReleaseComObject(xlApp); }
public Client(ClothesFactory clothesFactory) { _shirts = clothesFactory.CreateShirts(); _pants = clothesFactory.CreatePants(); }