Beispiel #1
0
 public DriverController(SchedulRepo schdb, AddressRepo addb, RegionRepo regdb, RequestRepo reqdb)
 {
     this.schdb = schdb;
     this.addb  = addb;
     this.regdb = regdb;
     this.reqdb = reqdb;
 }
        protected void gvOrders_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Order order = (Order)e.Row.DataItem;

            if (order != null)
            {
                OrderStatu orderStatus = new OrderStatusRepo().GetById(ToSQL.SQLToInt(order.OrderStatus_ID));
                if (orderStatus != null)
                {
                    e.Row.Cells[2].Text = orderStatus.Name;//order stat
                }
                Customer customer = new CustomerRepo().GetById(ToSQL.SQLToInt(order.Customer_ID));
                if (customer != null)
                {
                    e.Row.Cells[3].Text = customer.FirstName;//customer nam
                }
                Model.Payment payment = new PaymentRepo().GetById(ToSQL.SQLToInt(order.Payment_ID));
                if (payment != null)
                {
                    e.Row.Cells[4].Text = payment.Name;//payment method
                }
                ShippingAddress shippingAddress = new ShippingAddressRepo().GetById(ToSQL.SQLToInt(order.ShippingAddress_ID));
                if (shippingAddress != null)
                {
                    e.Row.Cells[5].Text = shippingAddress.Name;//Recipient's Name
                    e.Row.Cells[6].Text = shippingAddress.Phone;
                    string strAddress = new AddressRepo().GetToString(shippingAddress.Address);
                    e.Row.Cells[7].Text    = new AddressRepo().ShortString(strAddress);
                    e.Row.Cells[7].ToolTip = strAddress;
                }
            }
        }
Beispiel #3
0
 public IList <Address> GetAll(SQLiteConnection connection)
 {
     if (connection == null)
     {
         throw new ArgumentNullException("connection is null");
     }
     return(AddressRepo.GetAll(connection).ToList());
 }
Beispiel #4
0
 public Address Get(SQLiteConnection connection, int id)
 {
     if (id == 0)
     {
         throw new InvalidOperationException("id is 0");
     }
     return(AddressRepo.Get(connection, id));
 }
Beispiel #5
0
        /// <summary>
        /// Gets addresses by user
        /// </summary>
        /// <param name="userId">user id</param>
        /// <returns>List of addresses</returns>
        public async Task <IEnumerable <AddressDto> > GetUserAddresses(Guid userId)
        {
            var addressesDb = await AddressRepo
                              .GetAll(a => a.UserId == userId.ToString() && a.IsActive)
                              .ToListAsync();

            return(Mapper.Map <IEnumerable <AddressDto> >(addressesDb));
        }
Beispiel #6
0
        private void btnDeleteCustomer_Click(object sender, EventArgs e)
        {
            var selectedCustomer = (Customer)dgCustomers.SelectedRows[0].DataBoundItem;

            AppointmentRepo.DeleteAppointmentsForCustomer(selectedCustomer.Id);
            CustomerRepo.DeleteCustomer(selectedCustomer.Id);
            AddressRepo.DeleteAddress(selectedCustomer.AddressId);
            BindGrids();
        }
Beispiel #7
0
        public void GetTestA()
        {
            InitializeDatabase(new HardcodedDataV3());

            var _addressRepo = new AddressRepo();

            var output = _addressRepo.Get();

            Assert.Equal(9, output.Count());
        }
Beispiel #8
0
        public void GetTestD()
        {
            InitializeDatabase(new HardcodedDataV3());

            var _addressRepo = new AddressRepo();

            var output = _addressRepo.GetByEmployeeId(Guid.Parse("00000000-096D-4EE6-BC10-60A5E5E7A7FE"));

            Assert.Empty(output);
        }
Beispiel #9
0
 public AdminController(SchedulRepo schdb, Sch_col_Repo scoldb, RegionRepo regdb, UserRepo u, AddressRepo addb, comp_prom_repo _comp, Promotions_repo _prom, promcodes_repo _code)
 {
     this.schdb  = schdb;
     this.scoldb = scoldb;
     this.regdb  = regdb;
     this.u      = u;
     this.addb   = addb;
     this.comp   = _comp;
     this.prom   = _prom;
     this.code   = _code;
 }
Beispiel #10
0
        /// <summary>
        /// Method allowing to add address
        /// </summary>
        /// <param name="request">Add address request model</param>
        /// <returns>Added address</returns>
        public async Task <Address> CreateAddress(AddressAddRequest request)
        {
            var addressToAdd = Mapper.Map <AddressAddRequest, Address>(request);

            addressToAdd.IsActive = true;
            await AddressRepo.CreateAsync(addressToAdd);

            await AddressRepo.SaveChangesAsync();

            return(addressToAdd);
        }
Beispiel #11
0
        public void GetTestE()
        {
            InitializeDatabase(new HardcodedDataV3());

            var _addressRepo = new AddressRepo();

            var output = _addressRepo.GetByEmployeeId(Guid.Parse("51b0f8ee-17c2-4db0-8665-902261af9bfe"));

            Assert.Equal(3, output.Count());
            Assert.NotNull(output.FirstOrDefault(e => e.Id == Guid.Parse("332e0092-6526-4f2e-aa87-16605f8e0c96")));
        }
Beispiel #12
0
        public void GetTestB()
        {
            InitializeDatabase(new HardcodedDataV3());

            var _addressRepo = new AddressRepo();

            var output = _addressRepo.Get(Guid.Parse("BB45E083-096D-4EE6-BC10-60A5E5E7A7FE"));

            Assert.NotNull(output);
            Assert.Equal("City-I-Employee-F", output.City);
        }
Beispiel #13
0
 public void Add(SQLiteConnection connection, Address address)
 {
     if (address == null)
     {
         throw new ArgumentNullException("address is null");
     }
     if (connection == null)
     {
         throw new ArgumentNullException("connection is null");
     }
     AddressRepo.Add(connection, address);
 }
Beispiel #14
0
        private void btnCustomersByCity_Click(object sender, EventArgs e)
        {
            var cities = AddressRepo.GetAllCities();
            var report = $"Customers By City Report \n  Requested {DateTime.Now.ToString("f", DateTimeFormatInfo.InvariantInfo)} \n";

            foreach (var city in cities)
            {
                var customersInThisCity = Customers.Where(c => c.Address.CityId == city.Id).ToList();
                report += $"{city.Name}: {customersInThisCity.Count} customers \n";
            }

            MessageBox.Show(report);
        }
Beispiel #15
0
 public void Delete(SQLiteConnection connection, Address address)
 {
     if (connection == null)
     {
         throw new ArgumentNullException("connection is null");
     }
     if (address == null)
     {
         throw new ArgumentNullException("argument is null");
     }
     if (address.Id == 0)
     {
         throw new InvalidOperationException("address is not saved in Database");
     }
     AddressRepo.Delete(connection, address);
 }
Beispiel #16
0
 protected void gvUsers_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     Model.User user = (Model.User)e.Row.DataItem;
     if (user != null)
     {
         if (user.Address != null)
         {
             Label lbAddress = (Label)e.Row.FindControl("lblAddress");
             if (lbAddress != null)
             {
                 string strAddress = new AddressRepo().GetToString(user.Address);
                 lbAddress.Text    = new AddressRepo().ShortString(strAddress);
                 lbAddress.ToolTip = strAddress;
             }
         }
     }
 }
Beispiel #17
0
        public AllRepos(string ConnectionString)
        {
            AddressRepo.SetInstance(ConnectionString);
            TraderRepo.SetInstance(ConnectionString);
            Repos.ItemRepo.SetInstance(ConnectionString);
            TagAssocRepo.SetInstance(ConnectionString);
            TagRepo.SetInstance(ConnectionString);
            TransactionRepo.SetInstance(ConnectionString);


            Address      = AddressRepo.GetInstance();
            Traders      = TraderRepo.GetInstance();
            Items        = Repos.ItemRepo.GetInstance();
            TagAssoc     = TagAssocRepo.GetInstance();
            Tags         = TagRepo.GetInstance();
            Transactions = TransactionRepo.GetInstance();
        }
Beispiel #18
0
        /// <summary>
        /// Sets given address isActive to given value
        /// </summary>
        /// <param name="addressId">Address id</param>
        /// <param name="isActive">Value to set</param>
        /// <returns>True if operation was successful</returns>
        private async Task <bool> SetAddressIsActive(Guid addressId, bool isActive)
        {
            var addressDb = await AddressRepo
                            .GetAll()
                            .FirstOrDefaultAsync(a => a.Id == addressId);

            if (addressDb == null)
            {
                return(false);
            }

            addressDb.IsActive = isActive;

            AddressRepo.Update(addressDb);
            await AddressRepo.SaveChangesAsync();

            return(true);
        }
 protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         Model.Customer customer = (Model.Customer)e.Row.DataItem;
         if (customer != null)
         {
             if (customer.Address != null)
             {
                 Label lbAddress = (Label)e.Row.FindControl("lblAddress");
                 if (lbAddress != null)
                 {
                     string strAddress = new AddressRepo().GetToString(customer.Address);
                     lbAddress.Text    = new AddressRepo().ShortString(strAddress);
                     lbAddress.ToolTip = strAddress;
                 }
             }
         }
     }
 }
        public async Task <AddressModel> GetModelAsync(string latitude, string longitude)
        {
            try
            {
                _repo = new AddressRepo(latitude, longitude);
                var entity = await _repo.GetEntityAsync();

                AddressModel model = MapEntityToModel(entity);

                return(model);
            }
            catch (AutoMapper.AutoMapperMappingException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Unable to retrieve Address Model", ex);
            }
        }
Beispiel #21
0
        public StockyDataService()
        {
            if (Helpers.DBIdentification)
            {
                Stocky.DataAcesse.DataBase.DBConnection.Set("LocalHost", "Stocky");
            }
            else
            {
                Stocky.DataAcesse.DataBase.DBConnection.Set(@"7TECH-SVR1", "Stocky_LIVE", "applogin", "728652Hotdog");
            }


            StockRepo       = new StockRepo();
            TransactionRepo = new TransactionRepo();
            AddressRepo     = new AddressRepo();
            CatergoryRepo   = new CategoryRepo();
            PersonRepo      = new PersonRepo();
            UserRepo        = new UserRepo();
            ValueRepo       = new ValueBandRepo();
            VendorRepo      = new VendorRepo();
            ValidationRepo  = new ValidationRepo();
        }
Beispiel #22
0
        //public ActionResult ReliefList()
        //{
        //    IRepository<RecieverTB> repo = new RecieverRepo();
        //    return View(repo.GetAll().ToList());
        //}


        public ActionResult AreaCoverage()
        {
            IRepository <AddressTB> adrsRep = new AddressRepo();

            return(View(adrsRep.GetAll()));
        }
 public AddressManager()
 {
     _AddressRepo = new AddressRepo();
 }
Beispiel #24
0
        /// <summary>
        /// Rents 1st of avaible catridge copies by given cartridge id to given user
        /// Adds new Rental to database
        /// </summary>
        /// <param name="cartridgeId">Cartridge id</param>
        /// <param name="userId">User that wants to rent id</param>
        /// <param name="request">Rental request</param>
        /// <returns>Null if cartridge or user is not found. True if user could rent given cartridge, false otherwise.</returns>
        public async Task <bool?> RentCartridge(Guid cartridgeId, Guid userId, CartridgeRentRequest request)
        {
            var cartridge = await CartridgeRepo
                            .GetAll()
                            .AsNoTracking()
                            .FirstOrDefaultAsync(c => c.Id == cartridgeId);

            if (cartridge == null)
            {
                return(null);
            }

            var copy = await CartridgeCopyRepo
                       .GetAll()
                       .FirstOrDefaultAsync(c => c.CartridgeId == cartridgeId && c.Avaible);

            if (copy == null)
            {
                return(false);
            }

            var address = new Address();

            if (request.Delivery == collectionInPerson)
            {
                address = null;
            }
            else if (request.AddAddress)
            {
                request.NewAddress.UserId = userId.ToString();
                address = await AddressService.CreateAddress(request.NewAddress);
            }
            else
            {
                address = await AddressRepo
                          .GetAll()
                          .FirstOrDefaultAsync(a => a.Id == new Guid(request.AddressId));

                if (address == null)
                {
                    return(null);
                }
            }

            var shopUser = await ShopUserRepo
                           .GetAll()
                           .AsNoTracking()
                           .FirstOrDefaultAsync(su => su.UserId == userId.ToString());

            var rental = new Rental
            {
                DaysToReturn    = cartridge.DaysToReturn,
                RentPrice       = cartridge.RentPrice,
                Rented          = DateTime.UtcNow,
                AddressId       = address?.Id,
                CartridgeCopyId = copy.Id,
                Delivery        = request.Delivery,
                ShopUserId      = shopUser.Id,
            };

            copy.Avaible = false;

            await CartridgeCopyRepo.SaveChangesAsync();

            await RentalRepo.CreateAsync(rental);

            await RentalRepo.SaveChangesAsync();

            return(true);
        }
Beispiel #25
0
 public AddressController(AddressRepo addressRepo, RegionRepo regionRepo)
 {
     _addressRepo = addressRepo;
     _regionRepo  = regionRepo;
 }
Beispiel #26
0
 public AddressService()
 {
     _addressRepo = new AddressRepo();
 }