public void getItems() { items.Clear(); try { using (SqlConnection connection = new SqlConnection( global::GymMembershipSystem.Properties.Settings.Default.GymMembershipSystemDatabase)) { using (SqlCommand command = new SqlCommand("SELECT id, ItemName, ItemId, ItemPrice, ItemCount, ItemDescription" + " FROM Items", connection)) { command.CommandType = CommandType.Text; connection.Open(); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["id"]); string name = dr["ItemName"].ToString(); int itemid = Convert.ToInt32(dr["Itemid"]); decimal itemprice = Convert.ToDecimal(dr["ItemPrice"]); int itemcount = Convert.ToInt32(dr["ItemCount"]); string itemdesc = dr["ItemDescription"].ToString(); string itemurl = path.Trim() + "Images\\shopitems\\" + itemid.ToString() + ext; FullItem newItem = new FullItem(); newItem.id = id; newItem.ItemName = name; newItem.ItemId = itemid; newItem.ItemPrice = itemprice; newItem.ItemCount = itemcount; newItem.ItemDescription = itemdesc; newItem.ItemUrl = itemurl; items.Add(newItem); } connection.Close(); } } populate(); } catch (Exception ex) { List <Label> Labels = new List <Label>(); Labels.Add(MyLabel.SetOKLabel("General Error")); Labels.Add(MyLabel.SetOKLabel(ex.Message)); List <Button> Buttons = new List <Button>(); Buttons.Add(MyButton.SetOKThemeButton()); MyMessageBox.Show( Labels, "", Buttons, MyImage.SetFailed()); } }
public void DeleteFullItem(int Id) { if (_cntx.FullItem.Any(x => x.Id == Id)) { FullItem item = _cntx.FullItem.Find(Id); _cntx.FullItem.Remove(item); _cntx.SaveChanges(); } }
protected void TestUpdate_Click(object sender, EventArgs e) { FullItemDataRepository dataRepository = new FullItemDataRepository(); FullItem item = dataRepository.GetItemById(new Guid("42dec287-ae97-616c-accb-ff00009b0b8b")); item.ShortText = "new 22 ;) updated"; item.LongText = "uhaaaa"; item.SetChoicesSingle("1"); item.SetChoicesMultiple(new string[] { "2" }); item.YesNo = false; item.DateTime = new DateTime(2000, 1, 1); item.GuidField = new Guid("32200000-0000-0000-0000-000000000223"); item.ArrayOfGuids = new Guid[] { item.GuidField, item.GuidField, item.GuidField }; Address oldAddress = item.Address; oldAddress.City = "Kanzas"; item.Address = oldAddress; //////// item.ClearRelatedDynamicModuleMultiple(); item.AddRelatedDynamicModuleMultiple(this.GetRelatedItem(2)); item.SetRelatedDynamicModuleSingle(this.GetRelatedItem(0)); item.AddNewsRelatedDataMultiple(this.GetNewItem(2)); item.SetNewsRelatedDataSingle(this.GetNewItem(2)); item.SetFirstClassification(this.GetFirstTaxonItem(1).Id); item.ClearSecondClassification(); item.AddSecondClassification(this.GetSecondTaxonItem(0).Id, this.GetSecondTaxonItem(1).Id); item.ClearMultipleImageField(); item.AddMultipleImageField(this.GetImage(2)); item.AddMultipleImageField(this.GetImage(3)); item.SetSingleImageField(this.GetImage(1)); item.AddMultipleVideoField(this.GetVideo(2)); item.ClearSingleVideoField(); /////// dataRepository.Commit(); dataRepository.Publish(item); dataRepository.Commit(); }
public ViewResult EditFullItem(FullItem game) { if (ModelState.IsValid) { TempData["message"] = string.Format("Изменения в товаре \"{0}\" были сохранены", _repo.Items.First(x => x.Id == game.ItemId).Name); _repo.SaveFullItem(game); return(View("EditFullItem", game)); } else { return(View("EditFullItem", game)); } }
public void SaveFullItem(FullItem item) { if (_cntx.FullItem.Any(x => x.Id == item.Id)) { FullItem itemBase = _cntx.FullItem.Find(item.Id); itemBase.ItemId = item.ItemId; itemBase.Quantity = item.Quantity; itemBase.Size = item.Size; } else { _cntx.FullItem.Add(item); } _cntx.SaveChanges(); }
public void ProcessItem_RawData_MarksItemAsProcessed() { string data = "my test data"; var rawItem = new FullItem() { File = new UTF8Encoding().GetBytes(data), FileName = "test.txt", Received = DateTime.Now.ToUniversalTime(), ResourceId = Guid.NewGuid() }; var processor = new ItemProcessor(); var finishedItem = processor.ProcessItem(rawItem); Assert.IsTrue(finishedItem.IsProcessed); }
public void ProcessItem_LowerCaseData_IsUpperCased() { string data = "my test data"; var rawItem = new FullItem() { File = new UTF8Encoding().GetBytes(data), FileName = "test.txt", Received = DateTime.Now.ToUniversalTime(), ResourceId = Guid.NewGuid() }; var processor = new ItemProcessor(); var finishedItem = processor.ProcessItem(rawItem); string result = new UTF8Encoding().GetString(finishedItem.File); Assert.AreEqual(data.ToUpper(), result); }
private FullItem CreateItem(string title, FullItemDataRepository dataRepository) { FullItem newItem = dataRepository.Create(); newItem.ShortText = title; newItem.LongText = title; newItem.SetChoicesSingle("2"); newItem.SetChoicesMultiple(new string[] { "1", "2" }); newItem.YesNo = true; newItem.DateTime = new DateTime(1991, 12, 23); newItem.Number = 999; newItem.GuidField = new Guid("22200000-0000-0000-0000-000000000222"); newItem.ArrayOfGuids = new Guid[] { newItem.GuidField, newItem.GuidField, newItem.GuidField }; newItem.Address = this.GetAddress(); newItem.AddRelatedDynamicModuleMultiple(this.GetRelatedItem(0)); newItem.AddRelatedDynamicModuleMultiple(this.GetRelatedItem(1)); newItem.SetRelatedDynamicModuleSingle(this.GetRelatedItem(2)); newItem.AddNewsRelatedDataMultiple(this.GetNewItem(0)); newItem.AddNewsRelatedDataMultiple(this.GetNewItem(1)); newItem.SetNewsRelatedDataSingle(this.GetNewItem(2)); newItem.SetFirstClassification(this.GetFirstTaxonItem(0).Id); newItem.AddSecondClassification(this.GetSecondTaxonItem(1).Id, this.GetSecondTaxonItem(2).Id); newItem.AddMultipleImageField(this.GetImage(0)); newItem.AddMultipleImageField(this.GetImage(1)); newItem.SetSingleImageField(this.GetImage(3)); newItem.AddMultipleVideoField(this.GetVideo(0)); newItem.AddMultipleVideoField(this.GetVideo(1)); newItem.SetSingleVideoField(this.GetVideo(3)); newItem.AddMultipleFileField(this.GetDocument(0)); newItem.AddMultipleFileField(this.GetDocument(1)); newItem.SetSingleFileField(this.GetDocument(3)); return(newItem); }
protected void TestCreateButton_Click(object sender, EventArgs e) { FullItemDataRepository dataRepository = new FullItemDataRepository(); //FullItem item1 = this.CreateItem("new 11 :)", dataRepository); //FullItem item2 = this.CreateItem("new 22 :)", dataRepository); //dataRepository.Commit(); //dataRepository.Publish(item1); //dataRepository.Commit(); FullItem item = dataRepository.GetItemById(new Guid("42dec287-ae97-616c-accb-ff00009b0b8b")); dataRepository.Publish(item); dataRepository.Commit(); }
public ViewResult EditFullItem(int Id) { FullItem item = _repo.FullItems.FirstOrDefault(x => x.Id == Id); return(View(item)); }