Пример #1
0
 public void ChangeRent(Rent rent, Rent newRent)
 {
     FileDatabase fileDatabase = new FileDatabase("data");
     Predicate<Rent> predicate = x => x.Car == rent.Car && x.RentName == rent.RentName;
     int i = _rents.FindIndex(predicate);
     _rents[i] = newRent;
     fileDatabase.SaveToDatabase(_rents.ToArray());
 }
Пример #2
0
 public void DeleteRent(Rent rent)
 {
     FileDatabase fileDatabase = new FileDatabase("data");
     Predicate<Rent> predicate = x => x.Car == rent.Car && x.RentName == rent.RentName;
     int i = _rents.FindIndex(predicate);
     _rents.RemoveAt(i);
     fileDatabase.SaveToDatabase(_rents.ToArray());
 }
Пример #3
0
 public Property(int position, String name, PropertyColor color, int cost, Rent rent, int mortgageVal)
     : base(position, name, cost, mortgageVal, "Property")
 {
     this.Position = position;
     this.Name = name;
     this.OwnerID = -1; //interpreted as no owner
     this.Color = color;
     this.Cost = cost;
     this.Rent = rent;
     this.ImprovementLevel = ImprovementLevel.NoImprovement; //all spaces start with no improvements
     this.MortgageVal = mortgageVal;
     SetImprovementCost();
 }
        public async Task DeleteRentAsync(Reader reader, Rent rent)
        {
            var rentingReader = (await FindByConditionAsync(r => r.Id == reader.Id)).SingleOrDefault();

            if (rentingReader == null)
            {
                return;
            }

            rentingReader.Rents.Remove(rent);
            _context.Rents.Remove(rent);

            await SaveAsync();
        }
Пример #5
0
        // GET: Rent/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rent rent = db.Rents.Find(id);

            if (rent == null)
            {
                return(HttpNotFound());
            }
            return(View(rent));
        }
        public ActionResult Create(Rent rent)
        {
            try
            {
                _rentService.Post(rent);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                var teste = e.Message;
                return(View());
            }
        }
Пример #7
0
        // GET: MyDesk/Rents/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rent rent = await db.Rents.FindAsync(id);

            if (rent == null)
            {
                return(HttpNotFound());
            }
            return(View(rent));
        }
Пример #8
0
        /// <summary>
        /// Retourne une réservation par son ID.
        /// Pour Employés uniquement.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Rent GetRent(int id)
        {
            Rent _rent = new Rent();

            try
            {
                DataTable _table = DalRent.GetRentById(id);
                if (_table != null)
                {
                    if (_table.Rows.Count != 0)
                    {
                        DataRowView row  = _table.DefaultView[0];
                        Rent        temp = new Rent();
                        temp.Id              = (int)row["Id"];
                        temp.VehicleTypeId   = (int)row["Vehicle_Id"];
                        temp.CstmrId         = (int)row["Customer_Id"];
                        temp.ReservationDate = (DateTime)row["ReservationDate"];
                        temp.StartDate       = (DateTime)row["StartDate"];
                        temp.EndDate         = (DateTime)row["EndDate"];
                        temp.ToPay           = (decimal)row["ToPay"];
                        temp.Paid            = (decimal)row["Paid"];
                        temp.IsClosed        = (bool)row["IsClosed"];

                        if (row["PickupDate"] != DBNull.Value && row["ReturnDate"] != DBNull.Value)
                        {
                            temp.PickupDate = (DateTime)row["PickupDate"];
                            temp.ReturnDate = (DateTime)row["ReturnDate"];
                        }
                        if (row["Employee_Id"] != DBNull.Value)
                        {
                            temp.EmployeeId = (int)row["Employee_Id"];
                        }

                        _rent = temp;
                    }
                }
                return(_rent);
            }
            #region Catch
            catch (CstmEx cstmEx)
            {
                throw new CstmEx(ExType.dtaRead, cstmEx);
            }
            catch (Exception ex)
            {
                throw new CstmEx(ExType.srvrError, ex);
            }
            #endregion Catch
        }
        public async Task PayRentWithCardAsyncShouldNotAddExistingCart()
        {
            var options = new DbContextOptionsBuilder <PhotoparallelDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var dbContext = new PhotoparallelDbContext(options);

            var creditCardsService = new CreditCardsService(dbContext);

            var rent = new Rent()
            {
                Recipient  = "Gosho Goshev",
                TotalPrice = 500,
            };

            var user = new ApplicationUser()
            {
                UserName  = "******",
                FirstName = "Gosho",
                LastName  = "Goshev",
            };

            var card = new CreditCard()
            {
                Number   = "1234567891234567",
                Customer = user,
            };

            dbContext.CreditCards.AddRange(new List <CreditCard>
            {
                new CreditCard {
                    Number = "1234567891234567", Customer = user
                },
                new CreditCard {
                    Number = "1111111111111111", Customer = user
                },
                new CreditCard {
                    Number = "2222222222222222", Customer = user
                },
            });

            await dbContext.SaveChangesAsync();

            await creditCardsService.PayRentWithCardAsync(card, user, rent);

            var creditCards = await dbContext.CreditCards.ToListAsync();

            Assert.Equal(3, creditCards.Count);
        }
Пример #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         rptr_Rent.DataSource = Rent.D_set("SELECT R.RentID, RT.RentType, O.FName + ' ' + O.MName + ' ' + O.LName AS OwnerName, R.Availability, R.Furnished, R.BedRooms, R.BathRooms, R.Sqft, R.Amount, R.Negotiable FROM  Owner_Details AS O INNER JOIN Tbl_RentDetails AS R ON O.OwnerID = R.OwnerID INNER JOIN RentTypeDetails AS RT ON R.RentTypeID = RT.RentTypeID", "RentDetails").Tables[0];
         rptr_Rent.DataBind();
         if (Request.QueryString["msg"] != null)
         {
             if (Request.QueryString["msg"].ToString() == "0")
             {
                 Response.Write("<script>alert('Rent Details updated Successfully...!');</script>");
             }
         }
     }
 }
Пример #11
0
        public ActionResult DeleteConfirmed(long id)
        {
            Rent rent = unitOfWork.RentRepository.GetById(id);

            rent.Property.available = true;
            unitOfWork.PropertyRepository.Update(rent.Property);

            unitOfWork.ContractRepository.Delete(rent.Contract);
            unitOfWork.RentRepository.Delete(rent);



            unitOfWork.Save();
            return(RedirectToAction("Index"));
        }
Пример #12
0
        public static Rent ViewModelToModel(RentViewModel rentVM, Rent rent)
        {
            rent.Id         = rentVM.Id;
            rent.CustomerId = rentVM.CustomerId;
            rent.Customer   = rentVM.Customer;
            rent.VehicleId  = rentVM.VehicleId;
            rent.Vehicle    = rentVM.Vehicle;
            rent.PickupDate = rentVM.PickupDate;
            rent.ReturnDate = rentVM.ReturnDate;
            rent.TypeOfRent = rentVM.TypeOfRentEnum;
            rent.Daily      = rentVM.Daily;
            rent.Location   = rentVM.Location;

            return(rent);
        }
Пример #13
0
 public ExpensesModel()
 {
     WiFi          = new WiFi();
     Food          = new Food();
     Electricity   = new Electricity();
     Fun           = new Fun();
     Gas           = new Gas();
     GymMembership = new GymMembership();
     StudentLoans  = new Loans();
     Rent          = new Rent();
     PhoneBill     = new Phone();
     CarInsurance  = new CarInsurance();
     CarPayment    = new CarPayment();
     HuluSpotify   = new HuluSpotify();
 }
Пример #14
0
        public ActionResult Edit(String id, Rent updatedRent)
        {
            Rent rent = realEstateContexts.rents.SingleOrDefault(x => x.PropertyNo == id);

            rent.Street      = updatedRent.Street;
            rent.City        = updatedRent.City;
            rent.Ptype       = updatedRent.Ptype;
            rent.Rooms       = updatedRent.Rooms;
            rent.RefOwnerNo  = updatedRent.RefOwnerNo;
            rent.RefStaffNo  = updatedRent.RefStaffNo;
            rent.RefBranchNo = updatedRent.RefBranchNo;
            rent.Rent1       = updatedRent.Rent1;
            realEstateContexts.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #15
0
        // GET: Rents/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rent rent = await db.Rents.FindAsync(id);

            if (rent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FlatId = new SelectList(db.Flats, "ID", "FlatName", rent.FlatId);
            return(View(rent));
        }
Пример #16
0
        public ActionResult Create([Bind(Include = "RentalId,BuildDataID,Check_In,Check_Out,NumMonths,RoomPrice,TotalPrice,Instalments")] Rent rent)
        {
            if (ModelState.IsValid)
            {
                rent.TotalPrice  = rent.Calc_Total();
                rent.Instalments = rent.Calc_Installment();
                rent.NumMonths   = rent.GetNumberMonths();
                rent.RoomPrice   = rent.GetRoomPrice();
                db.Rents.Add(rent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rent));
        }
Пример #17
0
        public IActionResult Dodaj(Rent newRent)
        {
            if (!ModelState.IsValid || newRent.DateFrom > newRent.DateTo)
            {
                ViewBag.Rents = _context.Rents.Include(p => p.Car)
                                .OrderBy(p => p.IdRent)
                                .ToList();
                ViewBag.Cars = _context.Cars.OrderBy(t => t.IdCar).ToList();
                return(View("Index", newRent));
            }
            _context.Rents.Add(newRent);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Пример #18
0
        private void btOk_Click(object sender, EventArgs e)
        {
            Settings.Instance.ShowNumberInHeader = cbShowNumberInHeader.Checked;
            Settings.Instance.DefaultLibrarianId = (cmbLibrarians.SelectedItem as Librarian)?.Id;
            Settings.Instance.DataFolder         = tbDataFolder.Text;

            Settings.Save();
            Book.Save();
            Librarian.Save();
            Reader.Save();
            Rent.Save();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #19
0
        public void EnsureCapacity(int size)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("this", "Dispose() has already been called on this object.");
            }

            if (buffer.Array.Length >= size)
            {
                return;
            }

            buffer.Dispose();
            buffer = new Rent <byte>(size);
        }
Пример #20
0
 private void btnInsertRent_Click(object sender, EventArgs e)
 {
     _rent = new Rent();
     WriteToEntity();
     try
     {
         DataRepository.Rent.Insert(_rent);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     MessageBox.Show("등록되었습니다.");
     Close();
 }
Пример #21
0
        public void AddRent(int IdStaff, int IdUser, int IdBook, DateTime Issue, DateTime Return, int Count)
        {
            Rent rent = new Rent
            {
                Count   = Count,
                IdBooks = IdBook,
                IdStaff = IdStaff,
                IdUsers = IdUser,
                Issue   = Issue,
                Return  = Return,
            };

            GetRentTable().InsertOnSubmit(rent);
            Dc.SubmitChanges();
        }
Пример #22
0
        // GET: Rents/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rent rent = db.rents.Find(id);

            if (rent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BuildDataID = new SelectList(db.AdvertBuilding, "BuildDataID", "BuildingName", rent.BuildDataID);
            return(View(rent));
        }
Пример #23
0
        public void CanReturn_UserIsRentee_ReturnsTrue()
        {
            // Arrange
            var user = new User();

            var rent = new Rent {
                Rentee = user
            };

            // Act
            var result = rent.CanReturn(user);

            // Assert
            Assert.IsTrue(result);
        }
Пример #24
0
        internal void deleteOneRent()
        {
            Rent rent = bdsRent.Current as Rent;

            if (rent == null)
            {
                return;
            }
            if (Helpers.Helper.SureToDelete() == false)
            {
                return;
            }
            DataRepository.Rent.Delete(rent);
            bdsRent.Remove(rent);
        }
Пример #25
0
        // GET: Rents/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Rent rent = db.Rents.Find(id);

            if (rent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StoreID = new SelectList(db.Stores, "ID", "Name", rent.StoreID);
            return(View(rent));
        }
Пример #26
0
        public ActionResult Rent(int movieId)
        {
            Rent rent = new Rent
            {
                MovieId   = movieId,
                UserId    = User.Identity.GetUserId(),
                CreatedAt = DateTime.Now
            };

            _unitOfWork.Rent.AddRent(rent);

            _unitOfWork.CommitChanges();

            return(RedirectToAction("Details", new { id = movieId }));
        }
Пример #27
0
        public IActionResult Create(Rent newRent)
        {
            var p = _context.GetRentCar(newRent);

            Console.WriteLine(p);
            if (!ModelState.IsValid || p > 0 || (newRent.DateFrom > newRent.DateTo))
            {
                ViewBag.Rents = _context.GetRents();
                ViewBag.Cars  = _context.GetCars();

                return(View("Index", newRent));
            }
            _context.AddNewRent(newRent);
            return(RedirectToAction("Index"));
        }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string        pg = "Paying Guest";
        SqlDataReader drtype;

        if (!Page.IsPostBack)
        {
            string StmtView = "SELECT  R.RentID, RT.RentType, O.FName + ' ' + O.MName + ' ' + O.LName AS OwnerName,";
            StmtView            += "R.Availability, R.Image, R.Capasity, R.bathroom, R.gender,R.wifi,R.security,R.mess, R.Sqft, R.Amount,";
            StmtView            += " O.Addrs, O.Mobile, O.Landline, O.City, O.State, O.Email FROM  Owner_Details AS O INNER JOIN";
            StmtView            += " PG AS R ON O.OwnerID = R.OwnerID INNER JOIN RentTypeDetails AS RT ON R.RentTypeID = RT.RentTypeID where RT.RentType='" + ddl_Type.Text + "' and R.gender='" + dd_for.Text + "' ";
            rptr_View.DataSource = Rent.D_set(StmtView, "RentDetails").Tables[0];
            rptr_View.DataBind();
        }
    }
Пример #29
0
        private static void ShowRentedFilm(Rent rent)
        {
            var film = domainService.GetFilmByName(rent.FilmName);

            if (rent.Payment.Currency == Currency.BonusPoints)
            {
                Console.WriteLine(String.Format("{0} ({1}) {2} days (payed with {3} bonus points)",
                                                film.Name, film.Type, rent.DaysCount, rent.Payment.Cost));
            }
            else
            {
                Console.WriteLine(String.Format("{0} ({1}) {2} days {3} EUR",
                                                film.Name, film.Type, rent.DaysCount, rent.Payment.Cost));
            }
        }
Пример #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         rptr_RentType.DataSource = Rent.D_set("select * from RentTypeDetails", "RentDetails").Tables[0];
         rptr_RentType.DataBind();
         if (Request.QueryString["msg"] != null)
         {
             if (Request.QueryString["msg"].ToString() == "0")
             {
                 Response.Write("<script>alert('Rent Type updated Successfully...!');</script>");
             }
         }
     }
 }
Пример #31
0
        public void EditRent(Rent rent)
        {
            var s = (from x in carRental.Rent
                     where x.Rid == rent.Rid
                     select x).First();

            s.Rid          = rent.Rid;
            s.DateOfRental = rent.DateOfRental;
            s.DateOfReturn = rent.DateOfReturn;
            s.Client_Id    = rent.Client_Id;
            s.User_Id      = rent.User_Id;
            s.Vehicle_Id   = rent.Vehicle_Id;

            carRental.SaveChanges();
        }
Пример #32
0
        private void btDelete_Click(object sender, EventArgs e)
        {
            //удаление информации о текущем прокате. Спрашиваем у пользователя подтверждение
            if (MessageBox.Show("Вы уверены, что хотите удалить эту запись?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //Удаляем информацию, сохраняем список прокатов в файл и переходим к первой записи
                //(либо создаем ее, если после удаления больше не осталось ни одного проката)
                currentRent.IsDeleted = true;
                RefreshRents();
                Rent.Save();
                SelectFirstRent();

                toolStripStatusLabel1.Text = "Данные удалены.";
            }
        }
Пример #33
0
 public static void InsertRent(Rent Obj_Rent_Insert)
 {
     try
     {
         using (BikeRentalEntities db = new BikeRentalEntities())
         {
             db.Rents.Add(Obj_Rent_Insert);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #34
0
        public static void InsertRent(Rent rent)
        {
            IDbCommand command = null;
            try
            {
                command = DbActions.GetCommand();

                string data = string.Format("'{0}', '{1}', '{2}'", rent.Id, rent.Name, rent.Month);
                command.CommandText = string.Format(DbActions.InsertStatement, Rent.TableName, Rent.Columns, data);

                command.CommandType = CommandType.Text;

                command.ExecuteNonQuery();

            }
            finally
            {
                DbActions.DisposeCommand(command);
            }
        }
Пример #35
0
        static void Main()
        {
            Item sallingerBook = new Book("4adwlj4", "Catcher in the Rye", 20.00m, "J. D. Salinger", "fiction");
            Item threeManBook = new Book("84djesd", "Three Men in a Boat", 39.99m, "Jerome K. Jerome", new List<string> { "comedy" });
            Item acGame = new Game("9gkjdsa", "AC Revelations", 78.00m, "historical", AgeRestriction.Teen);
            Item bubbleSplashGame = new Game("r8743jf", "Bubble Splash", 7.80m, new List<string> { "child", "fun" });
            Item godfatherMovie = new Video("483252j", "The Godfather", 99.00m, 178, "crime");
            Item dieHardMovie = new Video("9853kfds", "Die Hard 4", 9.90m, 144, new List<string> { "action", "crime", "thriller" });

            DateTime today = DateTime.Now;

            DateTime fiveYearsAgo = today.AddYears(-5);

            Sale dieHardSale = new Sale(dieHardMovie, fiveYearsAgo);

            Console.WriteLine(dieHardSale.DateOfSale); // 1/30/2015 2:31:55 PM (today)

            Sale acSale = new Sale(acGame);

            Console.WriteLine(acSale.DateOfSale); // 1/30/2010 2:31:55 PM

            DateTime afterOneWeek = today.AddDays(30);

            Rent bookRent = new Rent(sallingerBook, today, afterOneWeek);

            Console.WriteLine(bookRent.RentState); // Pending

            DateTime lastMonth = today.AddDays(-34);

            DateTime lastWeek = today.AddDays(-8);

            Rent movieRent = new Rent(godfatherMovie, lastMonth, lastWeek);

            Console.WriteLine(movieRent.RentState); // Overdue

            movieRent.ReturnItem();

            Console.WriteLine(movieRent.RentState); // Returned

            Console.WriteLine(movieRent.ReturnDate); // 1/30/2015 2:41:53 PM
        }
Пример #36
0
 public void Setup()
 {
     rent = new Rent();
 }
Пример #37
0
 public ActionResult RedirectToPayment(Rent rents)
 {
     var rent = db.Rents.First(c => c.RentId == rents.RentId);
     var service = new RentManagerService(db);
     if (!service.ReservationTimer(rent.DateRent))
     {
         var car = db.Cars.FirstOrDefault(c => c.CarId == rent.CarId);
         car.IsReserved = false;
         car.IsRented = false;
         rent.RentAccepted = false;
         db.SaveChanges();
         return View("ReservationTimerErr");
     }
     return RedirectToAction("Payment", new {id = rent.RentId});
 }
Пример #38
0
        public static void UpdateRent(Rent rent)
        {
            IDbCommand command = null;
            try
            {
                command = DbActions.GetCommand();

                string data = string.Format("Name='{0}', Month='{1}'", rent.Name, rent.Month);
                command.CommandText = string.Format(DbActions.UpdateStatement, Rent.TableName, data, Rent.IdColumn, "'" + rent.Id + "'");

                command.CommandType = CommandType.Text;

                command.ExecuteNonQuery();
            }
            finally
            {
                DbActions.DisposeCommand(command);
            }
        }
Пример #39
0
        public IHttpActionResult Add()
        {
            var rent = new Rent {
                Id = Guid.NewGuid(),
                Name = "New Rent",
                Month = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
            };

            Database.Insert(rent);

            return this.Ok(Database.Get<Rent>(rent.Id));
        }
Пример #40
0
 public IHttpActionResult Update(Rent rent)
 {
     Database.Update(rent);
     return this.Ok(Database.Get<Rent>(rent.Id));
 }
Пример #41
0
        public HttpResponseMessage RentUpdate(Rent rent)
        {
            try
            {
                Database.Update(rent);
            }
            catch (Exception e)
            {
                return this.Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, e);
            }

            return this.Request.CreateResponse(HttpStatusCode.OK, new RowModel(rent));
        }
Пример #42
0
        public HttpResponseMessage RentAdd()
        {
            var rent = new Rent
            {
                Id = Guid.NewGuid(),
                Name = "New Rent",
                Month = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
            };

            try
            {
                Database.Insert(rent);
            }
            catch (Exception e)
            {
                return this.Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, e);
            }

            return this.Request.CreateResponse(HttpStatusCode.OK, new RowModel(rent));
        }