Exemplo n.º 1
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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)
                });
            }
        }
Exemplo n.º 6
0
        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);
                    }
                }
            }
        }
Exemplo n.º 7
0
        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
                    });
                }
            }
        }
Exemplo n.º 8
0
 public CreateModel(HOAContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 public IndexModel(HOAContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public EditModel(HOAContext context)
 {
     _context = context;
 }
Exemplo n.º 11
0
 public DeleteModel(HOAContext context)
 {
     _context = context;
 }
Exemplo n.º 12
0
 public LostKeyModel(HOAContext context)
 {
     _context = context;
 }
Exemplo n.º 13
0
 public ReturnKeyModel(HOAContext context)
 {
     _context = context;
 }