Example #1
0
        public IList <IMedia> GetBuildingMediaAssets(int buildingId, bool excludeFolders = true)
        {
            IList <IMedia> media      = new List <IMedia>();
            var            bldgFolder = _buildingFolderRepo.GetAll().FirstOrDefault(x => x.BuildingId == buildingId);

            if (bldgFolder != null)
            {
                var mediaFolder = GetMediaFolder(bldgFolder.FolderId);
                if (mediaFolder != null && _mediaService.HasChildren(mediaFolder.Id))
                {
                    //if found, get the assets
                    var childrenMedia = _mediaService.GetChildren(mediaFolder.Id).Where(m => !m.Trashed);
                    if (excludeFolders)
                    {
                        childrenMedia = childrenMedia.Where(m => !m.ContentType.Alias.Equals("folder", StringComparison.OrdinalIgnoreCase));
                    }

                    var enumerator = childrenMedia.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        //TODO: check if media exist/registered on building assets table
                        //if it exist on media library, make sure it is also registered on table
                        media.Add(enumerator.Current);
                    }
                }
            }

            return(media);
        }
Example #2
0
        private List <Apartment> MapData(DataTable table, int id = -1)
        {
            var list = new List <Apartment>(table.Rows.Count - 1);

            foreach (DataRow row in table.AsEnumerable())
            {
                var values      = row.ItemArray;
                var existingApt = _apartmentRepo
                                  .GetAll()
                                  .FirstOrDefault(a => a.Name.Equals(values[0].ToString(), StringComparison.OrdinalIgnoreCase) && a.BuildingId == id);

                if (existingApt != null)
                {
                    existingApt.Name     = values[0].ToString();
                    existingApt.StatusId = GetStatus(values[1].ToString()) != null?GetStatus(values[1].ToString()).Id : -1;

                    existingApt.Size          = values[2].ToString();
                    existingApt.NumberOfRooms = int.Parse(values[3].ToString());
                    existingApt.Price         = decimal.Parse(values[4].ToString());
                    existingApt.BuildingId    = id;
                    var isUpdatedApt = _apartmentRepo.Update(existingApt.Id, existingApt);
                    if (isUpdatedApt)
                    {
                        list.Add(existingApt);
                    }
                    continue;
                }
                else
                {
                    var apartment = new Apartment();
                    apartment.Name     = values[0].ToString();
                    apartment.StatusId = GetStatus(values[1].ToString()) != null?GetStatus(values[1].ToString()).Id : -1;

                    apartment.Size          = values[2].ToString();
                    apartment.NumberOfRooms = int.Parse(values[3].ToString());
                    apartment.Price         = decimal.Parse(values[4].ToString());
                    apartment.BuildingId    = id;
                    var newApartment = _apartmentRepo.Insert(apartment);
                    if (newApartment != null)
                    {
                        list.Add(newApartment);
                    }
                    continue;
                }
            }
            return(list);
        }
Example #3
0
 public IEnumerable <Building> GetAll()
 {
     return(_bldgRepo.GetAll());
 }
Example #4
0
 private AccountFolder GetAccountFolder(int accountId)
 {
     return(_accountFolderRepo.GetAll().FirstOrDefault(f => f.AccountId > 0 && f.AccountId == accountId));
 }
Example #5
0
        private ApartmentStatus GetStatus(string type)
        {
            var status = _apartmentStatusRepo.GetAll().FirstOrDefault(x => x.Name.Contains(type));

            return(status);
        }
Example #6
0
 public List <Apartment> GetApartments(int buildingId)
 {
     return(_apartmentRepo.GetAll().Where(a => a.BuildingId == buildingId).ToList());
 }