public ActionResult Create([Bind(Include = "id_renter,password,fname,lname,phone,cellphone,city,address,id_area")] Renters renters) { var q1 = db.Renters.Where(p => p.password == renters.password).FirstOrDefault(); var q = db.Renters.Where(p => p.fname == renters.fname && p.lname == renters.lname && p.phone == renters.phone && p.city == renters.city && p.address == renters.address && p.id_area == renters.id_area).FirstOrDefault(); if (ModelState.IsValid && q == null && q1 == null) { db.Renters.Add(renters); db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.classs = "alert alert-danger"; if (q != null) { ViewBag.ErrorExists = "קיים אדם כזה כבר, נסה שנית."; } if (q1 != null) { ViewBag.ErrorExists = "קיימת סיסמה כזו."; } } ViewBag.id_area = new SelectList(db.Areas, "id_area", "area", renters.id_area); return(View(renters)); }
public ActionResult AddRenter([Bind(Include = "id_renter,password,fname,lname,phone,cellphone,city,address,id_area")] Renters renters) { int error2 = 0; var q1 = db.Renters.FirstOrDefault(p => p.password == renters.password); var q = db.Renters.FirstOrDefault(p => p.fname == renters.fname && p.lname == renters.lname && p.phone == renters.phone && p.city == renters.city && p.address == renters.address && p.id_area == renters.id_area); if (ModelState.IsValid && q == null && q1 == null) { db.Renters.Add(renters); db.SaveChanges(); // } else { if (q != null) { error2 = 1; } if (q1 != null) { error2 = 2; } return(RedirectToAction("AddRenter", new { error = error2 })); } ViewBag.id_area = new SelectList(db.Areas, "id_area", "area", renters.id_area); return(RedirectToAction("AddGown", "Connection")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Passport,Phone,DriveExperience,Address")] Renters renters) { if (id != renters.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(renters); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentersExists(renters.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(renters)); }
public ActionResult Register(string fname, string lname, string phone, string cellphone, string address, string username, string password) { Users user = db.Users.FirstOrDefault(p => p.password == password && p.username == username); if (user != null) { return(RedirectToAction("Register", new { error = 1 })); } Renters renter = new Renters() { fname = fname, lname = lname, phone = phone, cellphone = cellphone, address = address }; db.Renters.Add(renter); db.SaveChanges(); renter = db.Renters.FirstOrDefault(p => p.fname == fname && p.lname == lname && p.phone == phone && p.cellphone == cellphone && p.address == address); int userid = db.Renters.Count(); if (renter != null) { userid = renter.id_renter; } user = new Users() { status = 2, password = password, username = username, userid = userid }; db.Users.Add(user); db.SaveChanges(); Session["user"] = new Renters(); Session["user"] = renter; return(RedirectToAction("Renter", "Renter")); }
public ActionResult DeleteConfirmed(int id) { Renters renters = db.Renters.Find(id); db.Renters.Remove(renters); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditProfile() { Renters renter = new Renters(); if (Session["user"] != null) { renter = (Session["user"] as Renters); } return(View(renter)); }
public ActionResult Edit([Bind(Include = "id_renter,password,fname,lname,phone,cellphone,city,address,id_area")] Renters renters) { if (ModelState.IsValid) { db.Entry(renters).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_area = new SelectList(db.Areas, "id_area", "area", renters.id_area); return(View(renters)); }
public ActionResult DeleteRenter(int?id) { Renters renter = db.Renters.FirstOrDefault(p => p.id_renter == id); if (renter != null) { renter.is_active = false; } db.SaveChanges(); return(RedirectToAction("ShowRenters")); }
public IActionResult AddNewRenter(Renters renter) { renter.RenterId = Guid.NewGuid().ToString(); Cars c = carsLogic.GetOneCar(renter.CarId); c.Available = false; carsLogic.Save(); rentersLogic.InsertRenter(renter); return(RedirectToAction(nameof(ListCars))); }
public async Task <IActionResult> Create([Bind("Id,Name,Passport,Phone,DriveExperience,Address")] Renters renters) { if (ModelState.IsValid) { _context.Add(renters); await _context.SaveChangesAsync(); return(RedirectToAction("Create", "Contracts")); //return RedirectToAction(nameof(Index)); } return(View(renters)); }
public ActionResult EditRenter([Bind(Include = "id_renter,fname,lname,phone,cellphone,address")] Renters oldRenter) { Renters renter = db.Renters.FirstOrDefault(p => p.id_renter == oldRenter.id_renter); renter.fname = oldRenter.fname; renter.lname = oldRenter.lname; renter.phone = oldRenter.phone; renter.cellphone = oldRenter.cellphone; renter.address = oldRenter.address; db.SaveChanges(); return(RedirectToAction("ShowRenters")); }
// GET: Renters/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Renters renters = db.Renters.Find(id); if (renters == null) { return(HttpNotFound()); } return(View(renters)); }
public async Task <IActionResult> Import(IFormFile fileExcel) { if (ModelState.IsValid) { if (fileExcel != null) { using (var stream = new FileStream(fileExcel.FileName, FileMode.Create)) { await fileExcel.CopyToAsync(stream); using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled)) { foreach (IXLWorksheet worksheet in workBook.Worksheets) { foreach (IXLRow row in worksheet.RowsUsed().Skip(1)) { Renters renters = new Renters(); if (row.Cell(1).Value.ToString().Length > 0) { var a = (from rent in _context.Renters where rent.Passport.Contains(row.Cell(1).Value.ToString()) select rent).ToList(); if (a.Count() > 0) { continue; } else { renters.Passport = row.Cell(1).Value.ToString(); } } renters.Phone = row.Cell(2).Value.ToString(); renters.DriveExperience = row.Cell(3).Value.ToString(); renters.Address = row.Cell(4).Value.ToString(); renters.Name = row.Cell(5).Value.ToString(); _context.Renters.Add(renters); if (row.Cell(1).Value.ToString().Length == 0 || row.Cell(2).Value.ToString().Length == 0 || row.Cell(3).Value.ToString().Length == 0 || row.Cell(4).Value.ToString().Length == 0 || row.Cell(5).Value.ToString().Length == 0) { return(NotFound()); } } } } } } await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); }
public AddRenterWindow(Renters r, TokenVM _token) { InitializeComponent(); this.name.Text = r.Name; this.postalCode.Text = r.PostalCode; this.city.Text = r.City; this.address.Text = r.Address; this.email.Text = r.Email; this.phoneNumber.Text = r.PhoneNumber; this.rentedDays.Text = r.RentedDays.ToString(); renter = r; token = _token; }
// GET: Renters/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Renters renters = db.Renters.Find(id); if (renters == null) { return(HttpNotFound()); } ViewBag.id_area = new SelectList(db.Areas, "id_area", "area", renters.id_area); return(View(renters)); }
public IActionResult DeleteRenter(string id) { Renters r = rentersLogic.GetOneRenter(id); Cars c = carsLogic.GetOneCar(r.CarId); if (c != null) { c.Available = true; } carsLogic.Save(); r.CarId = null; rentersLogic.DeleteRenter(id); return(RedirectToAction(nameof(ListRenters))); }
public ActionResult EditProfile([Bind(Include = "id_renter,fname,lname,phone,cellphone,address")] Renters oldRenter) { Renters renter = db.Renters.FirstOrDefault(p => p.id_renter == oldRenter.id_renter); renter.fname = oldRenter.fname; renter.lname = oldRenter.lname; renter.phone = oldRenter.phone; renter.cellphone = oldRenter.cellphone; renter.address = oldRenter.address; db.SaveChanges(); if (Session["user"] != null) { Session["user"] = renter; } return(RedirectToAction("Renter")); }
private void OK_Click(object sender, RoutedEventArgs e) { if (renter != null) { Renters r = new Renters() { Name = this.name.Text.ToString(), PostalCode = this.postalCode.Text.ToString(), City = this.city.Text.ToString(), Address = this.address.Text.ToString(), Email = this.email.Text.ToString(), PhoneNumber = this.phoneNumber.Text.ToString(), RentedDays = int.Parse(this.rentedDays.Text), CarId = renter.CarId, RenterId = renter.RenterId, }; RestService restService = new RestService(WebAddress.Address(), "/renter", token.Token); restService.Put <string, Renters>(renter.RenterId, r); renter = null; } else { Renters r = new Renters() { Name = this.name.Text.ToString(), PostalCode = this.postalCode.Text.ToString(), City = this.city.Text.ToString(), Address = this.address.Text.ToString(), Email = this.email.Text.ToString(), PhoneNumber = this.phoneNumber.Text.ToString(), RentedDays = int.Parse(this.rentedDays.Text), CarId = carId, }; RestService restService = new RestService(WebAddress.Address(), "/renter", token.Token); restService.Post <Renters>(r); } this.Close(); }
public async Task <IActionResult> DeleteConfirmed(int id) { //new IQueryable <Contracts> contracts = from o in _context.Contracts where o.RenterId == id select o; Renters renters = _context.Renters.Find(id); foreach (Contracts contracts1 in contracts) { _context.Contracts.Remove(contracts1); } _context.Renters.Remove(renters); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); //new /*var renters = await _context.Renters.FindAsync(id); * _context.Renters.Remove(renters); * await _context.SaveChangesAsync(); * return RedirectToAction(nameof(Index));*/ }
public void TestDeletingRenter() { Mock <IRepository <Renters> > renterRepo = new Mock <IRepository <Renters> >(); Renters renter = new Renters() { RenterId = Guid.NewGuid().ToString(), Name = "Kiss Gabor", PostalCode = "4034", City = "Debrecen", Address = "Elso utca 1.", Email = "*****@*****.**", PhoneNumber = "+31 880 308 7288", RentedDays = 11 }; renterRepo.Setup(repo => repo.Delete(It.IsAny <string>())); RentersLogic logic = new RentersLogic(renterRepo.Object); logic.DeleteRenter(renter.RenterId); renterRepo.Verify(repo => repo.Delete(renter.RenterId), Times.Once); }
public ActionResult Login(string name, string password) { Users user = db.Users.FirstOrDefault(u => u.username == name && u.password == password); if (user != null) { if (user.status == 1) {//מנהל Session["user"] = new Users(); Session["user"] = user; return(RedirectToAction("Manager", "Manager")); } else { //משכיר Renters renter = db.Renters.FirstOrDefault(p => p.id_renter == user.userid); Session["user"] = new Renters(); Session["user"] = renter; return(RedirectToAction("Renter", "Renter")); } } return(RedirectToAction("Login", new { error = 1 })); }
public ActionResult EditRenter(int?id) { Renters renter = db.Renters.FirstOrDefault(p => p.id_renter == id); return(View(renter)); }
public IActionResult EditRenter(Renters r) { rentersLogic.UpdateRenter(r.RenterId, r); return(RedirectToAction(nameof(ListRenters))); }
public IActionResult GenerateDB() { /*Salons *************************************/ Salons s = new Salons { SalonId = Guid.NewGuid().ToString(), City = "Budapest", Address = "Liszt Ferenc International Airport Terminal 2", PostalCode = "2200" }; Salons s1 = new Salons { SalonId = Guid.NewGuid().ToString(), City = "Budapest", Address = "Lövőház u. 2", PostalCode = "1024" }; Salons s2 = new Salons { SalonId = Guid.NewGuid().ToString(), City = "Budapest", Address = "Arany János u. 26-28", PostalCode = "1051" }; Salons s3 = new Salons { SalonId = Guid.NewGuid().ToString(), City = "Győr", Address = "Puskás Tivadar u. 9", PostalCode = "9027" }; Salons s4 = new Salons { SalonId = Guid.NewGuid().ToString(), City = "Sopron", Address = "Zrínyi Miklós u. 32", PostalCode = "9400" }; /*Cars ***************************************/ Cars c = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Audi", Model = "A6", ModelYear = 2019, BodyType = "Sedan", CombFuelEco = 9.4, Available = false, PricePerDay = 102100, SalonId = s2.SalonId }; Cars c1 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Audi", Model = "A4", ModelYear = 2018, BodyType = "Wagon", CombFuelEco = 7.5, Available = true, PricePerDay = 85397, SalonId = s2.SalonId }; Cars c2 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Audi", Model = "A1", ModelYear = 2020, BodyType = "Hatchback", CombFuelEco = 4.7, Available = true, PricePerDay = 34972, SalonId = s3.SalonId }; Cars c3 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Audi", Model = "A3", ModelYear = 2020, BodyType = "Hatchback", CombFuelEco = 7.8, Available = true, PricePerDay = 41567, SalonId = s.SalonId }; Cars c4 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Toyota", Model = "C-HR", ModelYear = 2018, BodyType = "SUV", CombFuelEco = 8.1, Available = false, PricePerDay = 30537, SalonId = s.SalonId }; Cars c5 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Volkswagen", Model = "Transporter", ModelYear = 2017, BodyType = "Van", CombFuelEco = 7.5, Available = false, PricePerDay = 53481, SalonId = s1.SalonId }; Cars c6 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Nissan", Model = "GT-R", ModelYear = 2020, BodyType = "Coupe", CombFuelEco = 13, Available = true, PricePerDay = 368798, SalonId = s2.SalonId }; Cars c7 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Nissan", Model = "300ZX", ModelYear = 2000, BodyType = "Coupe", CombFuelEco = 13, Available = false, PricePerDay = 198375, SalonId = s2.SalonId }; Cars c8 = new Cars { CarId = Guid.NewGuid().ToString(), Make = "Mitsubishi", Model = "Lancer Evolution VIII MR", ModelYear = 2005, BodyType = "Sedan", CombFuelEco = 10.9, Available = false, PricePerDay = 296378, SalonId = s2.SalonId }; /*Renters ************************************/ Renters r = new Renters { RenterId = Guid.NewGuid().ToString(), Name = "Kiss Gabor", PostalCode = "4034", City = "Debrecen", Address = "Elso utca 1.", Email = "*****@*****.**", PhoneNumber = "+31 880 308 7288", RentedDays = 11, CarId = c.CarId }; Renters r1 = new Renters { RenterId = Guid.NewGuid().ToString(), Name = "Nagy Aron", PostalCode = "1111", City = "Budapest", Address = "Masodik utca 2.", Email = "*****@*****.**", PhoneNumber = "+46 697 322 8112", RentedDays = 4, CarId = c4.CarId }; Renters r2 = new Renters { RenterId = Guid.NewGuid().ToString(), Name = "Toth Eszter", PostalCode = "1020", City = "Bécs", Address = "Harmadik utca 3.", Email = "*****@*****.**", PhoneNumber = "+86 918 333 5232", RentedDays = 21, CarId = c5.CarId }; Renters r3 = new Renters { RenterId = Guid.NewGuid().ToString(), Name = "Jerrome Wrightem", PostalCode = "90019", City = "Los Angeles", Address = "80 Havey Alley", Email = "*****@*****.**", PhoneNumber = "+86 619 977 2794", RentedDays = 30, CarId = c7.CarId }; Renters r4 = new Renters { RenterId = Guid.NewGuid().ToString(), Name = "Lakatos Brendon", PostalCode = "9028", City = "Győr", Address = "Negyedik utca 4.", Email = "*****@*****.**", PhoneNumber = "+51 442 752 0329", RentedDays = 4, CarId = c8.CarId }; salonsLogic.InsertSalon(s); salonsLogic.InsertSalon(s1); salonsLogic.InsertSalon(s2); salonsLogic.InsertSalon(s3); salonsLogic.InsertSalon(s4); carsLogic.InsertCar(c); carsLogic.InsertCar(c1); carsLogic.InsertCar(c2); carsLogic.InsertCar(c3); carsLogic.InsertCar(c4); carsLogic.InsertCar(c5); carsLogic.InsertCar(c6); carsLogic.InsertCar(c7); carsLogic.InsertCar(c8); rentersLogic.InsertRenter(r); rentersLogic.InsertRenter(r1); rentersLogic.InsertRenter(r2); rentersLogic.InsertRenter(r3); rentersLogic.InsertRenter(r4); return(RedirectToAction(nameof(Index))); }
private void buildRenters() { Renters = new Renters(); renters.getAll().ForEach(Renters.Add); renterDataGrid.ItemsSource = Renters; }
public void OnPostInsert() { RenterRepository.Insert(Renter); Renters.Add(Renter); }
public void InsertRenter([FromBody] Renters renter) { renter.RenterId = Guid.NewGuid().ToString(); rLogic.InsertRenter(renter); }
public void UpdateRenter(string renterid, Renters renter) { renterrepo.Update(renterid, renter); }
public void UpdateRenter(string renterid, Renters renter) { rLogic.UpdateRenter(renterid, renter); }
public void InsertRenter(Renters renter) { renterrepo.Insert(renter); }