public async Task <IActionResult> PutItem(Guid id, ItemEdit itemEditDTO) { if (id != itemEditDTO.Id) { return(BadRequest()); } var item = User.UserRole().Contains("Admin") ? (await _bll.ItemService.FirstOrDefaultAsync((Guid)id)) : (await _bll.ItemService.FirstOrDefaultAsync((Guid)id, User.UserGuidId())); if (item == null) { return(NotFound()); } item.Name = itemEditDTO.Name; item.Description = itemEditDTO.Description; item.Discount = itemEditDTO.Discount; item.Price = itemEditDTO.Price; item.BrandId = itemEditDTO.BrandId; await _bll.ItemService.UpdateAsync(item); try { await _bll.SaveChangesAsync(); return(Ok(itemEditDTO)); } catch (DbUpdateConcurrencyException) { } return(Ok()); }
public ActionResult Edit(int id, ItemEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ItemId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateItemService(); if (service.UpdateItem(model)) { TempData["SaveResult"] = "Your item was updated! Hopefully it does better this time..."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your item could not be updated. Please try again."); return(View(model)); }
private void dataGrid_DoubleClick(object sender, EventArgs e) { if (ItemEdit.Enabled) { ItemEdit.PerformClick(); } }
private void SetTile(Item tile, int x, int y) { var l = Map.CurrentLayer; var pgt = new Item(); ItemEdit.SetItem(pgt); if (pgt.IsFieldItem && CHK_FieldItemSnap.Checked) { // coordinates must be even (not odd-half) x &= 0xFFFE; y &= 0xFFFE; tile = l.GetTile(x, y); } var permission = l.IsOccupied(pgt, x, y); switch (permission) { case PlacedItemPermission.OutOfBounds: case PlacedItemPermission.Collision when CHK_NoOverwrite.Checked: System.Media.SystemSounds.Asterisk.Play(); return; } // Clean up original placed data if (tile.IsRoot && CHK_AutoExtension.Checked) l.DeleteExtensionTiles(tile, x, y); // Set new placed data if (pgt.IsRoot && CHK_AutoExtension.Checked) l.SetExtensionTiles(pgt, x, y); tile.CopyFrom(pgt); ReloadItems(); }
public string UpdateItem(ItemEdit model) { using (var ctx = new ApplicationDbContext()) { if (ctx.Items.Count(e => e.ItemId == model.ItemId) == 0) { return($"Media ID {model.ItemId} NOT found in table"); } int test = ctx.Items.Count(e => e.ItemId == model.ItemId && e.AddedBy == _userId); if (ctx.Items.Count(e => e.ItemId == model.ItemId && e.AddedBy == _userId) > 0) { var entity = ctx.Items.Single(e => e.ItemId == model.ItemId && e.AddedBy == _userId); // maybe check here to see if the entity has a name/description/type value and return the not found here if it doesnt? entity.Name = model.Name; entity.Description = model.Description; entity.Type = model.Type; return(ctx.SaveChanges() == 1 ? null : "Something Went Wrong"); } // find out why this doesnt work later but for now it's fine return("Item Not Found"); } }
private void dispView_ContentCellDblClick(object sender, AxgrproLib._IGRDisplayViewerEvents_ContentCellDblClickEvent e) { if (ItemEdit.Enabled) { ItemEdit.PerformClick(); } }
private void ReplaceTile(Item tile, int x, int y) { var l = Map.CurrentLayer; var pgt = new Item(); ItemEdit.SetItem(pgt); if (pgt.IsFieldItem && CHK_FieldItemSnap.Checked) { // coordinates must be even (not odd-half) x &= 0xFFFE; y &= 0xFFFE; tile = l.GetTile(x, y); } var permission = l.IsOccupied(pgt, x, y); switch (permission) { case PlacedItemPermission.OutOfBounds: System.Media.SystemSounds.Asterisk.Play(); return; } bool wholeMap = (ModifierKeys & Keys.Shift) != 0; var count = View.ReplaceFieldItems(tile, pgt, wholeMap); if (count == 0) { WinFormsUtil.Alert(MessageStrings.MsgFieldItemModifyNone); return; } LoadItemGridAcre(); WinFormsUtil.Alert(string.Format(MessageStrings.MsgFieldItemModifyCount, count)); }
public ActionResult Edit(int id) { ViewBag.StoreId = _id; if (IsAdmin()) { var service = CreateService(); if (service == null) { return(RedirectToAction("Login", "Account")); } var detail = service.GetItemByIdDetail(id); var model = new ItemEdit { ItemId = detail.ItemId, StoreId = detail.StoreId, ItemName = detail.ItemName, Description = detail.Description, OwnerId = detail.OwnerId }; return(View(model)); } return(RedirectToAction("Index", new { id = _id })); }
private void SetTile(Item tile, int x, int y) { var l = Map.CurrentLayer; var pgt = new Item(); ItemEdit.SetItem(pgt); var permission = l.IsOccupied(pgt, x, y); switch (permission) { case FieldItemPermission.OutOfBounds: case FieldItemPermission.Collision when CHK_NoOverwrite.Checked: System.Media.SystemSounds.Asterisk.Play(); return; } // Clean up original placed data if (tile.IsRoot && CHK_AutoExtension.Checked) { l.DeleteExtensionTiles(tile, x, y); } // Set new placed data if (pgt.IsRoot && CHK_AutoExtension.Checked) { l.SetExtensionTiles(pgt, x, y); } tile.CopyFrom(pgt); ReloadItems(); }
public IHttpActionResult Put(int id, [FromBody] ItemEdit editedItem) { // Ensure that an "editedItem" is in the entity body if (editedItem == null) { return(BadRequest("Must send an entity body with the request")); } // Ensure that the id value in the URI matches the id value in the entity body if (id != editedItem.ItemId) { return(BadRequest("Invalid data in the entity body")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var changedItem = m.ItemEdit(editedItem); if (changedItem == null) { // HTTP 400 return(BadRequest("Cannot edit the object")); } else { // HTTP 200 with the changed item in the entity body return(Ok(changedItem)); } }
private ActionResult Edit(ItemEdit item) { if (!ModelState.IsValid) { return(RedirectToAction("Edit", new { id = item.ItemID })); } return(View()); }
private void Menu_Bulk_Click(object sender, EventArgs e) { var editor = new BatchEditor(SpawnLayer.Tiles, ItemEdit.SetItem(new Item())); editor.ShowDialog(); SpawnLayer.ClearDanglingExtensions(0, 0, SpawnLayer.MaxWidth, SpawnLayer.MaxHeight); LoadItemGridAcre(); }
private void LoadEditors() { var data = GameInfo.Strings.ItemDataSource.ToList(); var field = FieldItemList.Items.Select(z => z.Value).ToList(); data.Add(field, GameInfo.Strings.InternalNameTranslation); ItemEdit.Initialize(data, true); PG_TerrainTile.SelectedObject = new TerrainTile(); }
public ActionResult Edit(int id) { if (id != 0) { ItemEdit item = hel.GetEdit(id); return(View(item)); } return(View("AddNew")); }
public bool UpdateItem(ItemEdit model) { var entity = ctx.Items.Single(e => e.ItemID == model.ItemID); entity.ItemID = model.ItemID; entity.Name = model.Name; entity.Description = model.Description; entity.LocationID = model.LocationID; return(ctx.SaveChanges() == 1); }
private void dataGrid_DoubleClick(object sender, EventArgs e) { if (((MouseEventArgs)e).Y <= 20) { return; } if (ItemEdit.Enabled) { ItemEdit.PerformClick(); } }
public ItemEdit GetEdit(int id) { var item = (from i in ctx.Items where i.Id == id && String.IsNullOrEmpty(i.flag) select i).FirstOrDefault(); var model = new ItemEdit() { Item = item }; return(model); }
public bool UpdateItem(ItemEdit item) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Items.Single(e => e.ItemId == item.ItemId && e.OwnerId == _userId); entity.ItemName = item.ItemName; entity.ItemDescription = item.ItemDescription; entity.ItemPrice = item.ItemPrice; entity.ItemCondition = item.ItemCondition; return(ctx.SaveChanges() == 1); } }
//GET: Item Edit public ActionResult Edit(int id) { var service = CreateItemService(); var detail = service.GetItemById(id); var model = new ItemEdit { ItemId = detail.ItemId, ItemName = detail.ItemName, ItemDescription = detail.ItemDescription, ItemType = detail.ItemType }; return(View(model)); }
public bool UpdateItem(ItemEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Items .Single(e => e.ItemId == model.ItemId && e.OwnerId == _userId); entity.ItemName = model.ItemName; entity.ItemDescription = model.ItemDescription; entity.ItemType = model.ItemType; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id)//GET method that gives a Seller a View in which they can update the Name, Description....for an item { var service = CreateItemService(); var update = service.GetItemById(id); var model = new ItemEdit { ItemName = update.ItemName, ItemDescription = update.ItemDescription, ItemPrice = update.ItemPrice, ItemCondition = update.ItemCondition, CategoryName = update.CategoryName }; return(View(model)); }
//UPDATE //Update Item By ID public IHttpActionResult Put(ItemEdit item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateItemService(); if (!service.UpdateItem(item)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateItem(ItemEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Items .Single(e => e.ItemId == model.ItemId); entity.ItemId = model.ItemId; entity.StoreId = model.StoreId; entity.ItemName = model.ItemName; entity.Price = model.Price; entity.Description = model.Description; return(ctx.SaveChanges() == 1); } }
public async Task <bool> UpdateItem(ItemEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = await ctx .Items .SingleAsync(i => i.Id == model.Id && i.OwnerId == _userId); entity.Name = model.Name; entity.Description = model.Description; entity.ModelNumber = model.ModelNumber; entity.SerialNumber = model.SerialNumber; entity.Value = model.Value; entity.ItemImageId = model.ItemImageId; return(await ctx.SaveChangesAsync() == 1); } }
//GET: Item/Edit public ActionResult Edit(int id) { var service = new ItemService(); var detail = service.GetItemByID(id); ViewBag.LocationID = new SelectList(ctx.Locations.ToList(), "ID", "Name"); var model = new ItemEdit { ItemID = detail.ItemID, Name = detail.Name, Description = detail.Description, LocationID = detail.LocationID, }; return(View(model)); }
public MuseumEditor(Museum museum) { InitializeComponent(); this.TranslateInterface(GameInfo.CurrentLanguage); Editor = new Core.MuseumEditor(museum); CAL_Date.MinDate = DateTime.MinValue; var str = GameInfo.Strings; ItemEdit.Initialize(str.ItemDataSource); for (int i = 0; i < Editor.Dates.Length; i++) { LB_Donations.Items.Add(Editor.GetDonationText(str, i)); } DialogResult = DialogResult.Cancel; LB_Donations.SelectedIndex = 0; }
// TODO: Figure out how to unit test editing data // This is currently broken //[TestMethod] public void ItemEdit() { // Arrange SetUpItemData(); SetupController(controller, HttpMethod.Put); var itemData = new ItemEdit { ItemId = 5, Title = "JavaScript: The Good Parts", Price = (decimal)39.99, Description = "Programming in Javscript" }; // Act //IHttpActionResult result = controller.Put(itemData.ItemId, itemData); // Assert //var negResult = result as OkNegotiatedContentResult<ItemBase>; //Assert.AreEqual(itemData.Title, negResult.Content.Title); }
public bool UpdateItem(ItemEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Items .Single(e => e.ItemId == model.ItemId); entity.ItemId = model.ItemId; entity.Name = model.Name; entity.Description = model.Description; entity.Price = model.Price; entity.Inventory = model.Inventory; entity.UpdatedUtc = DateTime.Now; entity.CategoryID = model.CategoryID; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, ItemEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ItemID != id) { ModelState.AddModelError("", "Wrong ID"); return(View(model)); } var service = new ItemService(); if (service.UpdateItem(model)) { return(RedirectToAction("Index")); } ModelState.AddModelError("", "Error"); return(View(model)); }
public PlayerHouseEditor(PlayerHouse[] houses, IReadOnlyList <Player> players, int index) { InitializeComponent(); this.TranslateInterface(GameInfo.CurrentLanguage); Houses = houses; Players = players; Manager = new RoomItemManager(houses[0].GetRoom(0)); var data = GameInfo.Strings.ItemDataSource; ItemEdit.Initialize(data, true); DialogResult = DialogResult.Cancel; for (var i = 0; i < Houses.Length; i++) { var obj = Houses[i]; LB_Items.Items.Add(GetHouseSummary(players, obj, i)); } LB_Items.SelectedIndex = index; }
private void LoadControlType() { UseCache = false; if (ItemVersionId == -1) { BindItemData(true); } else { BindItemData(); } //Item Edit itemEditControl = (ItemEdit)LoadControl(ItemControlToLoad); itemEditControl.ModuleConfiguration = ModuleConfiguration; itemEditControl.ID = Path.GetFileNameWithoutExtension(ItemControlToLoad); itemEditControl.VersionInfoObject = VersionInfoObject; phItemEdit.Controls.Add(itemEditControl); if (SecurityFilter.IsSecurityEnabled(PortalId)) { trCategoryPermissions.Visible = true; categoryPermissions = (CategoryPermissions)LoadControl("../CategoryControls/CategoryPermissions.ascx"); categoryPermissions.CategoryId = VersionInfoObject.ItemId; categoryPermissions.ModuleConfiguration = ModuleConfiguration; phCategoryPermissions.Controls.Add(categoryPermissions); } //Parent Category parentCategoryRelationships = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx"); parentCategoryRelationships.ExcludeCircularRelationships = true; parentCategoryRelationships.ModuleConfiguration = ModuleConfiguration; parentCategoryRelationships.LocalResourceFile = ItemRelationshipResourceFile; parentCategoryRelationships.VersionInfoObject = VersionInfoObject; parentCategoryRelationships.ListRelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(); parentCategoryRelationships.CreateRelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(); parentCategoryRelationships.AvailableSelectionMode = ListSelectionMode.Single; parentCategoryRelationships.FlatView = true; parentCategoryRelationships.ItemTypeId = ItemType.Category.GetId(); phParentCategory.Controls.Add(parentCategoryRelationships); //Related Categories //this.irRelated = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx"); //this.irRelated.ModuleConfiguration = ModuleConfiguration; //this.irRelated.LocalResourceFile = ItemRelationshipResourceFile; //this.irRelated.VersionInfoObject = VersionInfoObject; //this.irRelated.ListRelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(); //this.irRelated.CreateRelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(); //this.irRelated.AvailableSelectionMode = ListSelectionMode.Multiple; //this.irRelated.FlatView = true; //this.irRelated.ItemTypeId = ItemType.Category.GetId(); //this.phParentCategory.Controls.Add(this.irRelated); //Featured Articles featuredArticlesRelationships = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx"); featuredArticlesRelationships.ModuleConfiguration = ModuleConfiguration; featuredArticlesRelationships.VersionInfoObject = VersionInfoObject; featuredArticlesRelationships.LocalResourceFile = ItemRelationshipResourceFile; featuredArticlesRelationships.ListRelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(); featuredArticlesRelationships.CreateRelationshipTypeId = Util.RelationshipType.ItemToFeaturedItem.GetId(); featuredArticlesRelationships.AvailableSelectionMode = ListSelectionMode.Multiple; featuredArticlesRelationships.FlatView = true; featuredArticlesRelationships.EnableDates = true; featuredArticlesRelationships.AllowSearch = true; featuredArticlesRelationships.EnableSortOrder = true; featuredArticlesRelationships.ItemTypeId = ItemType.Article.GetId(); phFeaturedArticles.Controls.Add(featuredArticlesRelationships); //load approval status itemApprovalStatus = (ItemApproval)LoadControl(ApprovalControlToLoad); itemApprovalStatus.ModuleConfiguration = ModuleConfiguration; itemApprovalStatus.ID = Path.GetFileNameWithoutExtension(ApprovalControlToLoad); itemApprovalStatus.VersionInfoObject = VersionInfoObject; phApproval.Controls.Add(itemApprovalStatus); }
private void LoadControlType() { UseCache = false; if (ItemVersionId == -1) { BindItemData(true); //trArticleId.Visible = false; cmdDelete.Visible = false; } else { BindItemData(); cmdDelete.Visible = IsAdmin; } var av = (Article)VersionInfoObject; //Item Edit itemEditControl = (ItemEdit)LoadControl(ItemControlToLoad); itemEditControl.ModuleConfiguration = ModuleConfiguration; itemEditControl.ID = Path.GetFileNameWithoutExtension(ItemControlToLoad); itemEditControl.VersionInfoObject = VersionInfoObject; phControls.Controls.Add(itemEditControl); //Article Text Editor TeArticleText = (TextEditor)LoadControl("~/controls/TextEditor.ascx"); TeArticleText.HtmlEncode = false; TeArticleText.TextRenderMode = "Raw"; //TeArticleText.Width = ArticleEditWidth; //default values for the editor TeArticleText.Height = ArticleEditHeight; //default values for the editor TeArticleText.ChooseMode = true; phArticleText.Controls.Add(TeArticleText); TeArticleText.Text = av.ArticleText; //Parent Category Relationship parentCategoryRelationship = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx"); parentCategoryRelationship.ModuleConfiguration = ModuleConfiguration; parentCategoryRelationship.LocalResourceFile = ItemrelationshipResourceFile; parentCategoryRelationship.VersionInfoObject = VersionInfoObject; parentCategoryRelationship.ListRelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(); parentCategoryRelationship.CreateRelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(); parentCategoryRelationship.AvailableSelectionMode = ListSelectionMode.Single; parentCategoryRelationship.IsRequired = true; parentCategoryRelationship.FlatView = true; parentCategoryRelationship.ItemTypeId = ItemType.Category.GetId(); phParentCategory.Controls.Add(parentCategoryRelationship); //Related Category Relationship relatedCategoryRelationships = (ItemRelationships)LoadControl("../controls/ItemRelationships.ascx"); relatedCategoryRelationships.ModuleConfiguration = ModuleConfiguration; relatedCategoryRelationships.LocalResourceFile = ItemrelationshipResourceFile; relatedCategoryRelationships.VersionInfoObject = VersionInfoObject; relatedCategoryRelationships.ListRelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(); relatedCategoryRelationships.CreateRelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(); relatedCategoryRelationships.AvailableSelectionMode = ListSelectionMode.Multiple; relatedCategoryRelationships.IsRequired = false; relatedCategoryRelationships.FlatView = true; relatedCategoryRelationships.ItemTypeId = ItemType.Category.GetId(); phRelatedCategories.Controls.Add(relatedCategoryRelationships); //load approval status itemApprovalStatus = (ItemApproval)LoadControl(ApprovalControlToLoad); itemApprovalStatus.ModuleConfiguration = ModuleConfiguration; itemApprovalStatus.ID = Path.GetFileNameWithoutExtension(ApprovalControlToLoad); itemApprovalStatus.VersionInfoObject = VersionInfoObject; phApproval.Controls.Add(itemApprovalStatus); if (AllowTags) { var tagList = new StringBuilder(255); foreach (ItemTag it in VersionInfoObject.Tags) { tagList.Append(Tag.GetTag(it.TagId, PortalId).Name); tagList.Append(";"); } tagEntryControl = (TagEntry)LoadControl(TagControlToLoad); tagEntryControl.ModuleConfiguration = ModuleConfiguration; tagEntryControl.ID = Path.GetFileNameWithoutExtension(TagControlToLoad); tagEntryControl.TagList = tagList.ToString(); phTagEntry.Controls.Add(tagEntryControl); } else { } }