public void PopulateAssignedOwnerContacts(HOAContext context, Models.Owner owner) { var allContactTypes = context.ContactType; var allOwnerContacts = context.OwnerContactType.Where(o => o.OwnerID == owner.OwnerID); var ownerContacts = new HashSet <int>(owner.OwnerContactType.Select(o => o.ContactTypeID)); AssignedOwnerContacts = new List <AssignedOwnerContactType>(); foreach (var type in allContactTypes) { var contactInfo = ""; foreach (var contact in allOwnerContacts) { if (contact.ContactTypeID == type.ContactTypeID) { contactInfo = contact.ContactValue; break; } } AssignedOwnerContacts.Add(new AssignedOwnerContactType { ContactTypeID = type.ContactTypeID, ContactTypeValue = type.Value, ContactValue = contactInfo, Assigned = ownerContacts.Contains(type.ContactTypeID) }); } }
public void PopulateCategoryDropDownList(HOAContext _context, object selectedCategory = null) { var categoriesQuery = from d in _context.ClassifiedCategory orderby d.Description select d; CategorySelectList = new SelectList(categoriesQuery.AsNoTracking(), "ClassifiedCategoryID", "Description", selectedCategory); }
public void PopulateTransactionDropDownList(HOAContext _context, object selectedType = null) { var typeQuery = from d in _context.TransactionType orderby d.Description select d; TransactionTypeSL = new SelectList(typeQuery.AsNoTracking(), "TransactionTypeID", "Description", selectedType); }
public void PopulateAssetsDropDownList(HOAContext _context, object selectedAsset = null) { var departmentsQuery = from d in _context.CommonAreaAsset where d.Status == "Active" orderby d.AssetName // Sort by name. select d; CommonAreaAssetSL = new SelectList(departmentsQuery.AsNoTracking(), "CommonAreaAssetID", "AssetName", selectedAsset); }
public void PopulateAssignedLotInventoryData(HOAContext context, Lot lot) { var allInventoryItems = context.Inventory; var LotInventory = new HashSet <int>( lot.LotInventory.Select(l => l.InventoryID)); AssignedLotInventoryList = new List <AssignedLotInventory>(); foreach (var item in allInventoryItems) { AssignedLotInventoryList.Add(new AssignedLotInventory { InventoryID = item.InventoryID, Description = item.Description, Assigned = LotInventory.Contains(item.InventoryID) }); } }
public void UpdateLotInventory(HOAContext context, string[] selectedInventory, Lot lotToUpdate, int?whoID) { if (selectedInventory == null) { lotToUpdate.LotInventory = new List <LotInventory>(); return; } var selectedInventoryHS = new HashSet <string>(selectedInventory); var lotInventory = new HashSet <int>(lotToUpdate.LotInventory.Select(l => l.Inventory.InventoryID)); var whoEdited = context.Owner .Include(o => o.User) .Include(o => o.Address) .Include(a => a.OwnerContactType) .ThenInclude(oc => oc.ContactType) .FirstOrDefault(u => u.OwnerID == whoID); foreach (var item in context.Inventory) { if (selectedInventoryHS.Contains(item.InventoryID.ToString())) { if (!lotInventory.Contains(item.InventoryID)) { lotToUpdate.LotInventory.Add( new LotInventory { LotsID = lotToUpdate.LotID, InventoryID = item.InventoryID, Description = "", LastModifiedBy = whoEdited != null ? whoEdited.Initials : "SYS", LastModifiedDate = DateTime.Now }); } } else { if (lotInventory.Contains(item.InventoryID)) { LotInventory itemToRemove = lotToUpdate .LotInventory .SingleOrDefault(l => l.InventoryID == item.InventoryID); context.Remove(itemToRemove); } } } }
public void UpdateOwnerContacts(HOAContext context, string[] selectedContacts, Models.Owner owner, Models.Owner user) { owner.OwnerContactType = new List <OwnerContactType>(); List <string> contacts = new List <string>(selectedContacts); List <ContactType> contactTypes = new List <ContactType>(context.ContactType); foreach (var type in contactTypes) { if (!string.IsNullOrEmpty(contacts.ElementAt(contactTypes.IndexOf(type)))) { owner.OwnerContactType.Add(new OwnerContactType { ContactTypeID = context.ContactType.FirstOrDefault(c => c.Value == type.Value).ContactTypeID, ContactValue = contacts.ElementAt(contactTypes.IndexOf(type)), LastModifiedBy = user != null ? user.Initials : "SYS", LastModifiedDate = DateTime.Now }); } } }
public CreateModel(HOAContext context) { _context = context; }
public IndexModel(HOAContext context) { _context = context; }
public EditModel(HOAContext context) { _context = context; }
public DeleteModel(HOAContext context) { _context = context; }
public LostKeyModel(HOAContext context) { _context = context; }
public ReturnKeyModel(HOAContext context) { _context = context; }