private void setDbErrorMessage(Vendor dbValues, Vendor clientValues, CommunityPricingContext _context) { if (dbValues.OwnerID != clientValues.OwnerID) { ModelState.AddModelError("Vendor.OwnerID", $"Current value: {dbValues.OwnerID}"); } if (dbValues.VendorName != clientValues.VendorName) { ModelState.AddModelError("Vendor.VendorName", $"Current value: {dbValues.VendorName}"); } if (dbValues.VendorAddress1 != clientValues.VendorAddress1) { ModelState.AddModelError("Vendor.VendorAddress1", $"Current value: {dbValues.VendorAddress1}"); } if (dbValues.VendorAddress2 != clientValues.VendorAddress2) { ModelState.AddModelError("Vendor.VendorAddress2", $"Current value: {dbValues.VendorAddress2}"); } ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you. The " + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again."); }
private void setDbErrorMessage(Offering dbValues, Offering clientValues, CommunityPricingContext _context) { ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you. The " + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again."); }
public DI_BasePageModel( CommunityPricingContext context, IAuthorizationService authorizationService, UserManager <ApplicationUser> userManager ) : base() { Context = context; AuthorizationService = authorizationService; UserManager = userManager; }
public static async Task Archive(CommunityPricingContext _context) { ArchivedOfferings = await _context.ArchivedOffering.ToListAsync(); List <Offering> offerings = await _context.Offering.ToListAsync(); foreach (var offering in offerings) { //If I already have that guid in my archives, then get out //...maybe send a message up the ranks too. if (!ArchivedOfferings.Any(aO => aO.OfferingID == offering.OfferingID && aO.Date == offering.AsOfDate)) { ArchivedOffering archivedOffering = new ArchivedOffering(); archivedOffering.ArchivedOfferingID = Guid.NewGuid(); if (!ArchivedOfferings.Select(a => a.ArchivedOfferingID) .Contains(archivedOffering.ArchivedOfferingID)) { archivedOffering.OfferingID = offering.OfferingID; archivedOffering.Date = offering.AsOfDate; archivedOffering.Price = offering.ProductPricePerWeight; _context.ArchivedOffering.Add(archivedOffering); } else { } } else { var archivedOfferingToUpdate = await _context.ArchivedOffering.FirstOrDefaultAsync( aO => aO.OfferingID == offering.OfferingID && aO.Date == offering.AsOfDate); if (archivedOfferingToUpdate.Price != offering.ProductPricePerWeight) { _context.Entry(archivedOfferingToUpdate).Property("Price") .CurrentValue = offering.ProductPricePerWeight; } } } try { await _context.SaveChangesAsync(); } catch (Exception) { throw; } }
private void SetDbErrorMessage(ProductCategory dbValues, ProductCategory clientValues, CommunityPricingContext _context) { if (dbValues.Name != clientValues.Name) { ModelState.AddModelError("ProductCategory.Name", $"current value: {dbValues.Name}"); } ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you. The " + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again."); }
public SelectList MakeVendorSelectList(CommunityPricingContext _context, object selectedVendor = null) { var vendors = from v in _context.Vendor orderby v.VendorName select v; List <Vendor> modifiedVendors = new List <Vendor>(); foreach (var vendor in vendors) { vendor.VendorName = vendor.VendorName + " - " + vendor.VendorAddress1 + ", " + vendor.VendorAddress2; modifiedVendors.Add(vendor); } VendorSL = new SelectList(modifiedVendors, "VendorID", "VendorName", selectedVendor); return(VendorSL); }
private async Task SetDbErrorMessage(Product dbValues, Product clientValues, CommunityPricingContext _context) { if (dbValues.ProductName != clientValues.ProductName) { ModelState.AddModelError("Product.ProductName", $"Current value: {dbValues.ProductName}"); } if (dbValues.ProductDescr1 != clientValues.ProductDescr1) { ModelState.AddModelError("Product.ProductDescr1", $"Current value: {dbValues.ProductDescr1}"); } if (dbValues.ProductDescr2_Wt_Vol != clientValues.ProductDescr2_Wt_Vol) { ModelState.AddModelError("Product.ProductDescr2_Wt_Vol", $"Current value: {dbValues.ProductDescr2_Wt_Vol}"); } if (dbValues.Wholesaler != clientValues.Wholesaler) { ModelState.AddModelError("Product.Wholesaler", $"Current value: {dbValues.Wholesaler}"); } if (dbValues.ProductCategoryID != clientValues.ProductCategoryID) { ProductCategory dbProductCategory = await _context.ProductCategory.FindAsync(dbValues.ProductCategoryID); ModelState.AddModelError("Product.ProductCategoryID", $"Current value: {dbProductCategory.Name}"); } ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you. The " + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again."); }
private async Task ArchiveHelper(CommunityPricingContext _context) { List <Offering> Offerings = await _context.Offering.ToListAsync(); List <ArchivedOffering> ArchivedOfferings = await _context.ArchivedOffering.ToListAsync(); }