public void OnGet() { var lst = CarManagementDB.GetDb().GetCollection <Car>("Car").Find(_ => true).ToList(); foreach (var item in lst) { var cv = new CarViewModel(); cv.Transferee = item.Transferee; cv.Model = item.Model; cv.Color = item.Color; cv.Pelak = item.Pelak; cv.Deleted = item.Deleted; cv.Name = item.Name; cv.Id = item.Id; cv.TransfereeName = CarManagementDB.GetDb().GetCollection <Person>("Person") .Find(p => p.Id == item.Transferee).FirstOrDefault().Name; LstCarViewModel.Add(cv); } var person = CarManagementDB.GetDb().GetCollection <Person>("Person").Find(_ => true).ToList(); ViewData["transfreeId"] = new SelectList(person, "Id", "Name"); }
public void OnGet() { var person = CarManagementDB.GetDb().GetCollection <Person>("Person").Find(_ => true).ToList(); var car = CarManagementDB.GetDb().GetCollection <Car>("Car").Find(_ => true).ToList(); var mabda = CarManagementDB.GetDb().GetCollection <Vahed>("Vahed").Find(_ => true).ToList(); ViewData["DriverId"] = new SelectList(person, "Id", "Name"); ViewData["MabdaId"] = new SelectList(mabda, "Id", "Name"); ViewData["CarId"] = new SelectList(car, "Id", "Name"); var lm = CarManagementDB.GetDb().GetCollection <Mamoriat>("Mamoriat").Find(_ => true).ToList(); foreach (var item in lm) { LstMamoriat.Add(new MamoriatViewModel { Mamoriat = item, CarName = CarManagementDB.GetDb().GetCollection <Car>("Car") .Find(p => p.Id == item.CarId).FirstOrDefault().Name, CarPelak = CarManagementDB.GetDb().GetCollection <Car>("Car") .Find(p => p.Id == item.CarId).FirstOrDefault().Pelak, DriverName = CarManagementDB.GetDb().GetCollection <Person>("Person") .Find(p => p.Id == item.DriverId).FirstOrDefault().Name, MabdaName = CarManagementDB.GetDb().GetCollection <Vahed>("Vahed") .Find(p => p.Id == item.MabdaId).FirstOrDefault().Name, UserName = CarManagementDB.GetDb().GetCollection <User>("User") .Find(p => p.Id == item.UserId).FirstOrDefault().Name }); } }
public async Task <IActionResult> OnPostDeleteAsync() { if (Person.Id == string.Empty) { return(Page()); } await CarManagementDB.GetDb().GetCollection <Person>("Person") .DeleteOneAsync(x => x.Id == Person.Id); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostEditAsync() { await CarManagementDB.GetDb().GetCollection <Person>("Person") .UpdateOneAsync(x => x.Id == Person.Id, Builders <Person> .Update .Set(u => u.CellPhone, Person.CellPhone) .Set(u => u.MelliCode, Person.MelliCode) .Set(u => u.Name, Person.Name) ); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostEditAsync() { var person = CarManagementDB.GetDb().GetCollection <Person>("Person").Find(_ => true).ToList(); ViewData["transfreeId"] = new SelectList(person, "Id", "Name"); await CarManagementDB.GetDb().GetCollection <Car>("Car").UpdateOneAsync(x => x.Id == Car.Id, Builders <Car> .Update .Set(u => u.Model, Car.Model) .Set(u => u.Color, Car.Color) .Set(u => u.Name, Car.Name) .Set(u => u.Pelak, Car.Pelak) .Set(u => u.Transferee, Car.Transferee) ); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostDeleteAsync() { if (Car.Id == string.Empty) { return(Page()); } var person = CarManagementDB.GetDb().GetCollection <Person>("Person").Find(_ => true).ToList(); ViewData["transfreeId"] = new SelectList(person, "Id", "Name"); await CarManagementDB.GetDb().GetCollection <Car>("Car") .DeleteOneAsync(x => x.Id == Car.Id); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostEditAsync() { await CarManagementDB.GetDb().GetCollection <Mamoriat>("Mamoriat") .UpdateOneAsync(x => x.Id == Mamoriat.Id, Builders <Mamoriat> .Update .Set(u => u.CarId, Mamoriat.CarId) .Set(u => u.DriverId, Mamoriat.DriverId) .Set(u => u.Maghsad, Mamoriat.Maghsad) .Set(u => u.TarikhBargasht, Mamoriat.TarikhBargasht) .Set(u => u.TarikhRaft, Mamoriat.TarikhRaft) .Set(u => u.ZamanBargasht, Mamoriat.ZamanBargasht) .Set(u => u.ZamanRaft, Mamoriat.ZamanRaft) .Set(u => u.MabdaId, Mamoriat.MabdaId) .Set(u => u.ShomareNameh, Mamoriat.ShomareNameh) .Set(u => u.UserId, Mamoriat.UserId) .Set(u => u.KilometerBargasht, Mamoriat.KilometerBargasht) .Set(u => u.KilometerRaft, Mamoriat.KilometerRaft) ); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostCreateAsync() { await CarManagementDB.GetDb().GetCollection <Person>("Person").InsertOneAsync(Person); return(RedirectToPage("./Index")); }
public void OnGet() { // LstCar = CarManagementDB.GetDb().GetCollection<Car>("Car").Find(_ => true).ToList(); LstPerson = CarManagementDB.GetDb().GetCollection <Person>("Person").Find(_ => true).ToList(); }
public void Create(Avarez avarez) { CarManagementDB.GetDb().GetCollection <Avarez>("Avarez").InsertOne(avarez); }
public void Update(Avarez p) { CarManagementDB.GetDb().GetCollection <Avarez>("Avarez").UpdateOneAsync(x => x.Id == p.Id, Builders <Avarez> .Update .Set(u => u.Price, p.Price) .Set(u => u.Rahgiri, p.Rahgiri)); }
public async Task <IActionResult> OnPostCreateAsync() { await CarManagementDB.GetDb().GetCollection <Mamoriat>("Mamoriat").InsertOneAsync(Mamoriat); return(RedirectToPage("./Index")); }