示例#1
0
        public void MarkDeliveryAsCollected(long deliveryId)
        {
            using (var ctx = new PostRoomDataContext())
            {
                var delivery = ctx.Deliveries.Find(deliveryId);
                delivery.CollectionDate = DateTime.UtcNow;
                ctx.SaveChanges();

                NotifyCollectionFromApartment(delivery.ApartmentId);
            }
        }
示例#2
0
        internal int GetTotalOutstandingPackagesForApartment(long apartmentId)
        {
            using (var ctx = new PostRoomDataContext())
            {
                var package = (from d in ctx.Deliveries
                               join a in ctx.Apartments on d.ApartmentId equals a.ApartmentId
                               where a.ApartmentId == apartmentId && d.CollectionDate.HasValue == false
                               select d).Count();

                return(package);
            }
        }
示例#3
0
        public List <Delivery> GetItemsForCollection(long apartmentId)
        {
            using (var ctx = new PostRoomDataContext())
            {
                var deliveries = (from d in ctx.Deliveries
                                  join a in ctx.Apartments on d.ApartmentId equals a.ApartmentId
                                  where a.ApartmentId == apartmentId && d.CollectionDate.HasValue == false
                                  select d);

                return(deliveries.ToList());
            }
        }
示例#4
0
        public void RecordDelivery(long apartmentId, string recipient)
        {
            using (var ctx = new PostRoomDataContext())
            {
                ctx.Deliveries.Add(new Delivery()
                {
                    ApartmentId  = apartmentId,
                    Recipient    = recipient,
                    DeliveryDate = DateTime.UtcNow
                });

                ctx.SaveChanges();

                NotifyDeliveryToApartment(apartmentId);
            }
        }
示例#5
0
        public void MarkAllDeliveriesAsCollected(long apartmentId)
        {
            using (var ctx = new PostRoomDataContext())
            {
                var deliveries = (from d in ctx.Deliveries
                                  join a in ctx.Apartments on d.ApartmentId equals a.ApartmentId
                                  where a.ApartmentId == apartmentId
                                  select d);

                foreach (var delivery in deliveries)
                {
                    delivery.CollectionDate = DateTime.UtcNow;
                }

                ctx.SaveChanges();
            }
        }
示例#6
0
        public List <Apartment> SearchApartments(string search)
        {
            using (var ctx = new PostRoomDataContext())
            {
                var matchingApartments = ctx.Apartments.Where(a => a.FriendlyName.Contains(search)).ToList();

                List <Apartment> results = new List <Apartment>();

                foreach (var apartment in matchingApartments)
                {
                    results.Add(new Apartment()
                    {
                        ApartmentId = apartment.ApartmentId, FriendlyName = apartment.FriendlyName
                    });
                }

                return(results);
            }
        }
 public PropertyManager()
 {
     context = new PostRoomDataContext();
 }
 public ResidentManager()
 {
     context = new PostRoomDataContext();
 }