Ejemplo n.º 1
0
        public IHttpActionResult GetAllRent()
        {
            RentService rentService  = CreateRentService();
            var         rentProperty = rentService.GetRent();

            return(Ok(rentProperty));
        }
Ejemplo n.º 2
0
        private static void ReturnCar(ClientClass client)
        {
            Console.Clear();
            List <RentClass> rentsOfClient = RentService.GetRentsOfClient(client);

            if (rentsOfClient.Count == 0)
            {
                Console.Clear();
                Console.WriteLine("You have no rents");
                return;
            }

            foreach (var i in RentService.GetRentsOfClient(client))
            {
                Console.WriteLine("\nCar id: " + i.CurrentCar.CarId);
                Console.WriteLine("Car type: " + i.CurrentCar.Bodywork.Type);
                Console.WriteLine("Car color: " + i.CurrentCar.Bodywork.Color);
            }
            Console.Write("\nChoose car's id you want to return: ");
            if (UserInputInt(out int chosenCarId))
            {
                Console.Clear();
                CarClass tempCar = AutoParkService.SearchCarById(chosenCarId);
                if (tempCar != null && tempCar.CurrentClient == client)
                {
                    RentService.RemoveRent(RentService.GetRentByCarId(chosenCarId));
                    Console.WriteLine($"Car with id '{chosenCarId}' was successfully returned");
                    return;
                }
            }
            Console.Clear();
            Console.WriteLine("Id not found!");
        }
Ejemplo n.º 3
0
        public IHttpActionResult DeleteRentService(int serviceId)
        {
            RentService rentService = _unitOfWork.RentServices.Get(serviceId);

            if (rentService == null)
            {
                return(BadRequest("Rent Service could not be found."));
            }

            try
            {
                if (File.Exists(HttpRuntime.AppDomainAppPath + "Images\\" + rentService.Logo))
                {
                    File.Delete(HttpRuntime.AppDomainAppPath + "Images\\" + rentService.Logo);
                }

                _unitOfWork.RentServices.Remove(rentService);
                _unitOfWork.Complete();
            }
            catch
            {
                return(BadRequest("Rent Service could not be deleted"));
            }
            return(Ok());
        }
Ejemplo n.º 4
0
        static void Main()
        {
            //ClientClass client = ClientService.AddNewClient(new ClientClass(487, 0, "Danik", "+1234567"));
            Session.InitializeCars();
            ClientService.InitializeClients();
            RentService.InitializeRents();
            TransactionService.InitializeTransactions();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            List <CarClass> cars = AutoParkService.AutoPark;

            /*foreach (var i in cars)
             * {
             *  Console.WriteLine($"bodyworkSN = {i.Bodywork.SerialNumber}, engineSN = {i.Engine.SerialNumber}" +
             *      $", kilometrage = {i.Kilometrage}, cost = {i.Cost}" +
             *      $", carStatus = {i.CarStatus}");
             * }*/
            Console.WriteLine(SQLEngines.GetInstance().Search("24887"));
            Console.WriteLine(SQLBodyworks.GetInstance().Search("11414"));
            Console.WriteLine(SQLRents.GetInstance().Search("1"));
            //Console.WriteLine(SQLCars.GetInstance().Search("5"));
            //Application.Run(new WorkForm(client));
            //Console.WriteLine(SQLClients.GetInstance().Search("Danik"));

            Application.Run(new LoginForm());
        }
Ejemplo n.º 5
0
        private RentService CreateRentService()
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var rentService = new RentService(userId);

            return(rentService);
        }
 public InvoiceController()
 {
     _billService       = new BillService();
     _rentService       = new RentService();
     _userDetailService = new UserDetailService();
     _carService        = new CarService();
 }
        public void BasicConsume_WithIModelAndEventHandler_InvokesBasicConsumeFromModel()
        {//public virtual string BasicConsume(string queue, bool autoAck, string consumerTag, bool noLocal, bool exclusive, IDictionary<string, object> arguments, IBasicConsumer consumer)
            modelMocker.Setup(o => o.BasicConsume(
                                  It.IsAny <string>(),
                                  It.IsAny <bool>(),
                                  It.IsAny <string>(),
                                  It.IsAny <bool>(),
                                  It.IsAny <bool>(),
                                  It.IsAny <IDictionary <string, object> >(),
                                  It.IsAny <IBasicConsumer>()))
            .Returns(string.Empty);
            RentService sut = GetSut();

            sut.BasicConsume(modelMocker.Object, eventingBasicConsumer);

            modelMocker.Verify(o => o.BasicConsume(
                                   It.IsAny <string>(),
                                   It.IsAny <bool>(),
                                   It.IsAny <string>(),
                                   It.IsAny <bool>(),
                                   It.IsAny <bool>(),
                                   It.IsAny <IDictionary <string, object> >(),
                                   It.IsAny <IBasicConsumer>()),
                               Times.Once);
        }
Ejemplo n.º 8
0
 public HomeController()
 {
     _rentService       = new RentService();
     _userDetailService = new UserDetailService();
     _carService        = new CarService();
     _contactService    = new ContactService();
 }
        public async Task <ActionResult <RentService> > PostRentService(RentService rentService)
        {
            _context.RentService.Add(rentService);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRentService", new { id = rentService.ServiceId }, rentService));
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press enter to start proccessing ...");
            Console.ReadLine();

            var rentFilterParams = new RentsFilterParams();

            AuthenticationService.Authorize(new Model.CurrentUserViewModel
            {
                Email    = "*****@*****.**",
                Password = "******"
            });

            var rentsResult = RentService.GetRents(rentFilterParams);

            UpdateRents(rentsResult.Collection);

            var totalPages = Math.Ceiling((double)rentsResult.TotalCount / rentFilterParams.Take);

            for (var i = 2; i <= totalPages; i++)
            {
                rentFilterParams.Skip = rentFilterParams.Take * (i - 1);

                var rents = RentService.GetRents(rentFilterParams);
                UpdateRents(rents.Collection);
            }
        }
Ejemplo n.º 11
0
        public IHttpActionResult Get(int Id)
        {
            RentService rentService  = CreateRentService();
            var         rentProperty = rentService.GetRentById(Id);

            return(Ok(rentProperty));
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            ICarService      carService      = new CarService(new EfCarDal());
            IBrandService    brandService    = new BrandService(new EfBrandDal());
            IRentService     rentService     = new RentService(new EfRentDal());
            IColorService    colorService    = new ColorService(new EfColorDal());
            ICustomerService customerService =
                new CustomerService(new EfCustomerDal());
            IUserService userService = new UserService(new EfUserDal());

            //var brands = new EfBrandDal();
            //Console.WriteLine(brands.Get(p => p.Id == 325) == null ? "No record" : "Found");

            //RentDetailsDtoTest(rentService);
            //CarDetailsDtoTest(carService);            //OK.
            //BrandServiceTest(brandService);           //OK.
            //CarServiceTest(carService);               //OK.
            //ColorServiceTest(colorService);           //OK.
            //CustomerServiceTest(customerService);     //OK.
            //RentServiceTest(rentService);             //OK.
            //UserListTest(userService);                //OK.
            //AddNewUserTest(userService);              //OK.
            //AddNewCustomer(customerService);
            //AddNewRentTest(rentService);                //OK.
            DeleteRentTest(rentService);
            //RemoveUserTest(userService);
        }
Ejemplo n.º 13
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         RentService.AddNewRent(new RentClass(client, (CarClass)listBox1.SelectedItem));
         MessageBox.Show($"Car with id {((CarClass)listBox1.SelectedItem).CarId} was successfully rented", "Autopark");
         this.Close();
     }
 }
        public void LoadConnection_WithIConnection_InvokesLoadChannel()
        {
            connectionFactoryMocker.Setup(o => o.CreateConnection()).Returns(connection);
            consoleServiceMocker.Setup(o => o.LoadChannel(connection));
            RentService sut = GetSut();

            sut.LoadConnection(connectionFactoryMocker.Object);

            consoleServiceMocker.Verify(o => o.LoadChannel(connection), Times.Once);
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         RentClass rent = RentService.GetRentByCarId(((RentClass)listBox1.SelectedItem).CurrentCar.CarId);
         RentService.RemoveRent(RentService.GetRentByCarId(((RentClass)listBox1.SelectedItem).CurrentCar.CarId));
         MessageBox.Show(string.Format($"Car with id {((RentClass)listBox1.SelectedItem).CurrentCar.CarId} was successfully returned"));
         this.Close();
         return;
     }
 }
        public void LoadConnection_WithIModle_InvokesQueueDeclare()
        {
            connectionMocker.Setup(o => o.CreateModel()).Returns(model);
            consoleServiceMocker.Setup(o => o.QueueDeclare(model));
            consoleServiceMocker.Setup(o => o.BasicConsume(model, It.IsAny <EventingBasicConsumer>()));
            RentService sut = GetSut();

            sut.LoadChannel(connectionMocker.Object);

            consoleServiceMocker.Verify(o => o.QueueDeclare(model), Times.Once);
        }
        public ReturnRentedCarForm(ClientClass client)
        {
            this.client = client;
            InitializeComponent();
            int lHeight = RentService.GetRentsOfClient(client).Count * 13 + 10;

            listBox1.DataSource = RentService.GetRentsOfClient(client);
            button1.Location    = new Point(button1.Location.X, button1.Location.Y - (listBox1.Height - lHeight));
            listBox1.Height     = lHeight;
            Height = lHeight + 150;
        }
Ejemplo n.º 18
0
        public void CarCantBeRentedFromServiceWithNoCarsTest()
        {
            RentService service        = new RentService(); // сервис без машин
            string      required_model = "Lada Kalina";
            string      required_color = "yellow";
            DateTime    startOfRent    = new DateTime(2017, 1, 1);
            DateTime    endOfRent      = new DateTime(2017, 1, 2);
            Client      client         = new Client("Иванов Иван", "1234567890");
            bool        rentResult     = client.RentCar(service, required_model, required_color, startOfRent, endOfRent);

            Assert.AreEqual(rentResult, false);
        }
Ejemplo n.º 19
0
        public void GetCurrentLogReturnsString()
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Orders.GetAll()).Returns(new List <Order>());

            //Act
            var service = new RentService(mockUow.Object);
            var result  = service.GetCurrentLog("somePath");

            //Assert
            Assert.That(result, Is.TypeOf(typeof(string)));
        }
Ejemplo n.º 20
0
        public void SearchCarsByFilterTest()
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Cars.GetAll()).Returns(new List <Car>());

            //Act
            var service = new RentService(mockUow.Object);
            var result  = service.GetCars(new FilterDTO());

            //Assert
            Assert.That(result, Is.TypeOf(typeof(List <CarDTO>)));
        }
Ejemplo n.º 21
0
        public static void main(string[] args)
        {
            ICarService carService = new CarService(new EfCarDal());

            IRentService rentService = new RentService(new EfRentDal());

            //var liste = rentService.GetAllNotReturned(DateTime.Now);
            foreach (var rent in rentService.GetAllNotReturned(DateTime.Now))
            {
                Console.WriteLine(rent.RentDate + " "
                                  + carService.GetById(rent.CarId).Plate + " "
                                  + rent.RentDate + " " + rent.EstReturnDate);
            }
        }
Ejemplo n.º 22
0
        public void GetReviewsTest()
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Reviews.GetAll()).Returns(new List <Review>());

            //Act
            var service = new RentService(mockUow.Object);
            var result  = service.GetReviews();

            //Assert
            Assert.That(result, Is.TypeOf(typeof(List <ReviewDTO>)));
        }
Ejemplo n.º 23
0
        public void GetOrderTest(int?id)
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Orders.Get(It.IsAny <int>())).Returns(new Order());

            //Act
            var service = new RentService(mockUow.Object);
            var result  = service.GetOrder(id);

            //Assert
            Assert.That(result, Is.TypeOf(typeof(OrderDTO)));
        }
Ejemplo n.º 24
0
        public void GetOrderByUserIdTest(string userId)
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Orders.GetAll()).Returns(new List <Order>());

            //Act
            var service = new RentService(mockUow.Object);
            var result  = service.GetOrders(userId);

            //Assert
            Assert.That(result, Is.TypeOf(typeof(List <OrderDTO>)));
        }
Ejemplo n.º 25
0
        public void SearchOrdersByCarAndUserTest(string searchCar, string searchUser)
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Orders.GetAll()).Returns(new List <Order>());

            //Act
            var service = new RentService(mockUow.Object);
            var result  = service.GetOrders(searchCar, searchUser);

            //Assert
            Assert.That(result, Is.TypeOf(typeof(List <OrderDTO>)));
        }
Ejemplo n.º 26
0
        public void DeleteReviewValidationTest(int?id)
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Reviews.Get(-1)).Returns((Review)null);

            //Act
            var service = new RentService(mockUow.Object);

            //Assert
            Assert.Throws <ValidationException>(
                () =>
                service.DeleteReview(id));
        }
Ejemplo n.º 27
0
        public void GetCarValidationTest(int?id)
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Cars.Get(It.IsAny <int>())).Returns((Car)null);

            //Act
            var service = new RentService(mockUow.Object);

            //Assert
            Assert.Throws <ValidationException>(
                () =>
                service.GetCar(id));
        }
Ejemplo n.º 28
0
        public void GetOrderByUserIdValidationTest(string id)
        {
            //Arrange
            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(a => a.Orders.Get(It.IsAny <int>())).Returns((Order)null);

            //Act
            var service = new RentService(mockUow.Object);

            //Assert
            Assert.Throws <ValidationException>(
                () =>
                service.GetOrders(id));
        }
        private static void RentProduct(RentService rentService)
        {
            Console.Write("Enter the product name to rent: ");
            string name = Console.ReadLine();

            Product product = rentService.RentProduct(name);

            if (product == null)
            {
                ShowErrors(Mediator);
            }
            else
            {
                Console.WriteLine($"Product {product.Name} rented!");
            }
        }
Ejemplo n.º 30
0
        private void button2_Click(object sender, EventArgs e)
        {
            List <RentClass> rentsOfClient = RentService.GetRentsOfClient(client);

            if (rentsOfClient.Count == 0)
            {
                MessageBox.Show("You have no rents", "Autopark");
                return;
            }
            else
            {
                this.Hide();
                ReturnRentedCarForm rrc = new ReturnRentedCarForm(client);
                rrc.Closed += (s, args) => this.Show();
                rrc.Show();
            }
        }