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()); }
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()); }
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(); }
// 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()); } }
// 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)); }
/// <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); }
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>"); } } } }
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")); }
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); }
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(); }
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")); }
// 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)); }
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)); }
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")); }
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(); }
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); }
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(); }
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(); }
// 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)); }
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); }
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); }
// 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)); }
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 })); }
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")); }
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(); } }
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)); } }
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>"); } } } }
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(); }
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 = "Данные удалены."; } }
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; } }
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); } }
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 }
public void Setup() { rent = new Rent(); }
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}); }
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); } }
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)); }
public IHttpActionResult Update(Rent rent) { Database.Update(rent); return this.Ok(Database.Get<Rent>(rent.Id)); }
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)); }
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)); }