예제 #1
0
        public void Rent_Per_Family_GetCost_3rents()
        {
            float expectedCostResult = (float)(160 * (0.7));

            RentPerWeek rent1 = new RentPerWeek();
            RentPerWeek rent2 = new RentPerWeek();
            RentPerDay  rent3 = new RentPerDay();

            rent3.DaysQuantity = 2;

            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent1);   //Initialize Rent By Week cost
            rentManager.Initialize(rent2);   //Initialize Rent By Week cost
            rentManager.Initialize(rent3);   //Initialize Rent By Week cost

            FamilyRent rent = new FamilyRent();

            rentManager.Initialize(rent);
            List <Rent> rents = new List <Rent> {
                rent1, rent2, rent3
            };

            rent.AddRents(rents);

            /*rent.AddRent(rent1);
            *  rent.AddRent(rent2);
            *  rent.AddRent(rent3);*/

            float?totalCostResult = rentManager.FamilyRent_GetTotalAmount(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #2
0
        public void Rent_Per_Family_GetCost_6rents()
        {
            RentPerHour rent1 = new RentPerHour();
            RentPerHour rent2 = new RentPerHour();

            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent1);   //Initialize Rent
            rentManager.Initialize(rent2);   //Initialize Rent

            FamilyRent rent = new FamilyRent();

            rentManager.Initialize(rent);
            rent.AddRent(rent1);            //Adding 6 rents
            rent.AddRent(rent2);
            rent.AddRent(rent1);
            rent.AddRent(rent2);
            rent.AddRent(rent1);
            rent.AddRent(rent2);

            try
            {
                float?totalCostResult = rentManager.FamilyRent_GetTotalAmount(rent);
            }
            catch (Exception ex)
            {
                Assert.AreEqual <string>(ex.Message, "Family Rental, need include from 3 to 5 Rentals. This Family Rental only have 6 rents.");
            }
        }
예제 #3
0
        public void Rent_Per_Hour_GetCost_WhitoutInitialize()
        {
            RentPerHour rent        = new RentPerHour();
            RentManager rentManager = new RentManager();
            //rentManager.Initialize(rent);   //Whitout Initialize
            //rent.HoursQuantity = 3;         //Whitout set any hours.
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.IsNull(totalCostResult);
        }
예제 #4
0
        public HttpResponseMessage Delete(int RentIdParam)
        {
            bool           Result      = RentManager.DeleteRent(RentIdParam);
            HttpStatusCode responsCode = Result ? HttpStatusCode.OK : HttpStatusCode.BadRequest;

            return(new HttpResponseMessage(responsCode)
            {
                Content = new ObjectContent <bool>(Result, new JsonMediaTypeFormatter())
            });
        }
예제 #5
0
 public HttpResponseMessage Get()
 {
     RentModel[] RentsArr = RentManager.GetAllRents();
     if (RentsArr == null)
     {
         return(new HttpResponseMessage(HttpStatusCode.BadRequest));
     }
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <RentModel[]>(RentsArr, new JsonMediaTypeFormatter())
     });
 }
예제 #6
0
 public HttpResponseMessage Get(string StringParam)
 {
     RentModel[] RentArr = RentManager.GetSpesificRent(StringParam);
     if (RentArr == null)
     {
         return(new HttpResponseMessage(HttpStatusCode.BadRequest));
     }
     return(new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new ObjectContent <RentModel[]>(RentArr, new JsonMediaTypeFormatter())
     });
 }
예제 #7
0
        public void Rent_Per_Week_GetCost_OneWeek()
        {
            float expectedCostResult = 60;

            RentPerWeek rent        = new RentPerWeek();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Week cost
            //rent.WeeksQuantity = 3;         //Whitout set any Weeks.
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #8
0
        public void Rent_Per_Week_GetCost_ManyWeeks()
        {
            float expectedCostResult = 120;

            RentPerWeek rent        = new RentPerWeek();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Week cost
            rent.WeeksQuantity = 2;         //Set rent on 2 weeks
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #9
0
        public void Rent_Per_Day_GetCost_OneDay()
        {
            float expectedCostResult = 20;

            RentPerDay  rent        = new RentPerDay();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Day cost
            //rent.DaysQuantity = 3;         //Whitout set any days.
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #10
0
        public void Rent_Per_Day_GetCost_ManyDays()
        {
            float expectedCostResult = 80;

            RentPerDay  rent        = new RentPerDay();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);  //Initialize Rent By Day cost
            rent.DaysQuantity = 4;         //Set rent on 4 Days
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #11
0
        public void Rent_Per_Hour_GetCost_ManyHours()
        {
            float expectedCostResult = 15;

            RentPerHour rent        = new RentPerHour();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Hour cost
            rent.HoursQuantity = 3;         //Set rent on 3 hours
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #12
0
        public HttpResponseMessage Get(int RentIdParam)
        {
            RentModel SingleRent = RentManager.GetSpesificRent(RentIdParam);

            if (SingleRent == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent <RentModel>(SingleRent, new JsonMediaTypeFormatter())
            });
        }
예제 #13
0
        public void Rent_Per_Hour_GetCost_OneHour()
        {
            float expectedCostResult = 5;

            RentPerHour rent        = new RentPerHour();
            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent);   //Initialize Rent By Hour cost
            //rent.HoursQuantity = 3;         //Whitout set any hours.
            float?totalCostResult = rentManager.GetTotalCostRent(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #14
0
        public HttpResponseMessage Put(int RentIdParam, [FromBody] RentModel rentparam)
        {
            bool updateResult = false;

            if (ModelState.IsValid)
            {
                updateResult = RentManager.EditRent(RentIdParam, rentparam);
            }
            HttpStatusCode rsponseCode = (updateResult) ? HttpStatusCode.OK : HttpStatusCode.BadRequest;

            return(new HttpResponseMessage(rsponseCode)
            {
                Content = new ObjectContent <bool>(updateResult, new JsonMediaTypeFormatter())
            });
        }
예제 #15
0
        public HttpResponseMessage Post([FromBody] RentModel value)
        {
            bool InsertResult = false;

            if (ModelState.IsValid)
            {
                InsertResult = RentManager.AddNewRent(value);
            }
            HttpStatusCode ResponsCode = InsertResult ? HttpStatusCode.Created : HttpStatusCode.BadRequest;

            return(new HttpResponseMessage(ResponsCode)
            {
                Content = new ObjectContent <bool>(InsertResult, new JsonMediaTypeFormatter())
            });
        }
예제 #16
0
        private static void RentCarTest()
        {
            var rentManager = new RentManager(new EfRentDal());
            var result      = rentManager.Add(new Rent {
                CarId = 1, CustomerId = 1, RentDate = DateTime.Now, ReturnDate = null
            });

            System.Console.WriteLine(result.Message);

            //foreach (var rent in rentManager.GetAll().Data)
            //{

            //    System.Console.WriteLine(rent.CarId);

            //}
        } //sıkıntı var
예제 #17
0
        static void Main(string[] args)
        {
            //BusinessManager businessManager = new BusinessManager(new EfCarDal());

            //businessManager.Update(new Car { Id = 5, Name = "cba", BrandId = 1, ColorId = 1, DailyPrice = 00 });

            //Console.WriteLine("GetALL");


            //Print(businessManager);

            //Car car = NewCar(businessManager);

            //businessManager.Add(car);

            //Console.WriteLine("------Added-------");

            //Print(businessManager);

            //businessManager.Delete(car);

            //Console.WriteLine("-----Deleted-----");

            //Print(businessManager);

            //Console.WriteLine("-----Updated-----");

            //businessManager.Update(new Car { Id = 5, Name = "xxx", BrandId = 1, ColorId = 1, DailyPrice = 00 });

            //Print(businessManager);

            RentManager rentManager = new RentManager(new EfRentDal());

            rentManager.Add(new Rental {
                CarId = 1, CustomerId = 1
            });
            rentManager.Add(new Rental {
                CarId = 2, CustomerId = 1
            });

            var result = rentManager.GetAll().Data;

            foreach (var item in result)
            {
                Console.WriteLine("{2}, {1}, {0}, {3}, {4}", item.CarId, item.CustomerId, item.Id, item.RentDate, item.ReturnDate);
            }
        }
예제 #18
0
        private static void RentDetailsTest()
        {
            RentManager rentManager = new RentManager(new EfRentDal());
            var         result      = rentManager.GetRentDetails();

            foreach (var rent in result.Data)
            {
                Console.WriteLine(
                    rent.RentId + "/" +
                    rent.CarDescription + "/" +
                    rent.CustomerName + "/" +
                    rent.FirstName + "/" +
                    rent.LastName + "/" +
                    rent.RentDate + "/" +
                    rent.ReturnDate);
            }
        }
예제 #19
0
        public void Rent_Per_Family_GetCost_5rents()
        {
            float expectedCostResult = (float)((20 + 15 + 20 + 5 + 5) * (0.7));

            RentPerHour rent1 = new RentPerHour();
            RentPerHour rent2 = new RentPerHour();
            RentPerDay  rent3 = new RentPerDay();
            RentPerHour rent4 = new RentPerHour();
            RentPerHour rent5 = new RentPerHour();

            rent1.HoursQuantity = 4;
            rent2.HoursQuantity = 3;

            RentManager rentManager = new RentManager();

            rentManager.Initialize(rent1);   //Initialize Rent
            rentManager.Initialize(rent2);   //Initialize Rent
            rentManager.Initialize(rent3);   //Initialize Rent
            rentManager.Initialize(rent4);   //Initialize Rent
            rentManager.Initialize(rent5);   //Initialize Rent

            FamilyRent rent = new FamilyRent();

            rentManager.Initialize(rent);
            List <Rent> rents = new List <Rent> {
                rent1, rent2, rent3
            };

            rent.AddRents(rents);
            rent.AddRent(rent4);
            rent.AddRent(rent5);

            float?totalCostResult = rentManager.FamilyRent_GetTotalAmount(rent);

            Assert.AreEqual(expectedCostResult, totalCostResult);
        }
예제 #20
0
 public HomePage()
 {
     Rooms = new List <Rent>();
     this.InitializeComponent();
     Rooms = RentManager.getRooms();
 }
예제 #21
0
 private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
 {
     locationButton.Content = "Kathmandu";
     RentManager.Getroom("Flat", locationButton.Content.ToString(), PriceButton.Content.ToString(), Rooms);
 }
예제 #22
0
 public BuildingPage()
 {
     Rooms = new ObservableCollection <Rent>();
     this.InitializeComponent();
     RentManager.Getroom("House", Rooms);
 }
예제 #23
0
 private void MenuFlyoutItem_Click_3(object sender, RoutedEventArgs e)
 {
     PriceButton.Content = "2000-3000";
     RentManager.Getroom("House", locationButton.Content.ToString(), PriceButton.Content.ToString(), Rooms);
 }
예제 #24
0
 public RoomPage()
 {
     Rooms = new ObservableCollection <Rent>();
     this.InitializeComponent();
     RentManager.Getroom("Room", Rooms);
 }
예제 #25
0
 private void MenuFlyoutItem_Click_4(object sender, RoutedEventArgs e)
 {
     locationButton.Content = "Bhaktapur";
     RentManager.Getroom("Room", locationButton.Content.ToString(), PriceButton.Content.ToString(), Rooms);
 }
예제 #26
0
 public void CreateRentManager(string firstName, string lastName, string userId)
 {
     var rentManager = new RentManager { UserFirstName = firstName, UserLastName = lastName, ApplicationUserId = userId };
     db.RentManagers.Add(rentManager);
     db.SaveChanges();
 }