public async Task <DriverVm> GetDriverByIdAsync(string id) { DriverVm driverUser = await idctx.Users.Where(p => p.Id == id). Select(d => new DriverVm { Email = d.Email, StreetAdress = d.StreetAdress, ZipCode = d.ZipCode, City = d.City, PhoneNumber = d.PhoneNumber, UserName = d.UserName, Image = d.Image }) .SingleOrDefaultAsync(); var driver = await appctx.Driver.Where(p => p.AspNetUsersId == id). Select(d => new { d.Description, d.A, d.B, d.C, d.Ce, d.D, d.FirstName, d.LastName }).SingleOrDefaultAsync(); driverUser.Description = driver.Description; driverUser.A = driver.A; driverUser.B = driver.B; driverUser.C = driver.C; driverUser.CE = driver.Ce; driverUser.D = driver.D; driverUser.FirstName = driver.FirstName; driverUser.LastName = driver.LastName; return(driverUser); }
public IActionResult DriverList() { if (HttpContext.Session.GetString("UserRole") != null) { var s = _context.Drivers.AsNoTracking().ToList(); var dr = new List <DriverVm>(); int c = 1; foreach (var item in s) { DriverVm se = new DriverVm() { DriverVmId = item.DriverId, Name = item.Name, Address = item.Address, Mobile = item.Mobile, LicenseNumber = item.LicenseNumber, }; se.DriverSerial = c; c++; dr.Add(se); } return(View(dr)); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <IActionResult> AddDriver(DriverVm model, IFormFile driverfile) { string filePath = null; if (driverfile != null) { filePath = await _fileUploadService.AddFile(driverfile); } if (!ModelState.IsValid) { return(this.ReturnModelErrorsAsJson()); } var driver = new Driver { CarrierId = _carrierService.Carrier.Id, Fio = model.Fio, PhoneNumber = model.PhoneNumber, IsActive = true, HasContract = model.HasContract, FilePath = filePath }; _dbContext.Drivers.Add(driver); await _dbContext.SaveChangesAsync(); return(PartialView("_Driver", driver)); }
public async Task <ActionResult> Add() { var driverVm = new DriverVm { driverLookupDTO = await new DriverService(AUTHTOKEN, p_mobileNo).LookUpDataAsync(), driver = new Driver() }; return(View(driverVm)); }
public async Task <ActionResult> Add() { // ViewData["Operators"] = (await new OperatorService(AUTHTOKEN, p_mobileNo).GetOperatorList()).Select(x => new { Value = x.OperatorID, Text = x.OperatorName }).ToList(); var driverVm = new DriverVm { driverLookupDTO = await new DriverService(AUTHTOKEN, p_mobileNo).LookUpDataAsync(), driver = new Driver() }; return(View(driverVm)); }
public async Task <ActionResult> Add() { ViewBag.Operators = (await new OperatorService(AUTHTOKEN, p_mobileNo).GetOperatorList()).Select(x => new { Value = x.OperatorID, Text = x.OperatorName }).ToList(); var driverVm = new DriverVm { driverLookupDTO = await new DriverService(AUTHTOKEN, p_mobileNo).LookUpDataAsync(), driver = new Driver() }; driverVm.driver.DateofIssue = DateTime.Now; driverVm.driver.DateofReturn = DateTime.Now; return(View(driverVm)); }
public async Task <ActionResult> Edit(string driverID) { Task <Driver> taskDriver = new DriverService(AUTHTOKEN, p_mobileNo).DriverInfoAsync(driverID); Task <DriverLookupDTO> taskDriverLookupDTO = new DriverService(AUTHTOKEN, p_mobileNo).LookUpDataAsync(); await Task.WhenAll(taskDriver, taskDriverLookupDTO); var driverVm = new DriverVm { driverLookupDTO = await taskDriverLookupDTO, driver = await taskDriver }; return(View(driverVm)); }
public IActionResult NewDriver(DriverVm d) { Driver di = new Driver() { DriverId = d.DriverVmId, Name = d.Name, Address = d.Address, LicenseNumber = d.LicenseNumber, Mobile = d.Mobile }; _context.Drivers.Add(di); _context.SaveChanges(); ModelState.Clear(); return(View()); }
// GET: Admin public ActionResult Index() { using (CarInsuranceEntities db = new CarInsuranceEntities()) { var drivers = db.Drivers.ToList(); var driverVms = new List <DriverVm>(); foreach (var driver in drivers) { var driverVm = new DriverVm(); driverVm.Id = driver.Id; driverVm.FirstName = driver.FirstName; driverVm.LastName = driver.LastName; driverVm.EmailAddress = driver.EmailAddress; driverVm.Quote = driver.Quote; driverVms.Add(driverVm); } return(View(driverVms)); } }
public IActionResult UpdateDriver(int id) { if (HttpContext.Session.GetString("UserRole") == "1") { var item = _context.Drivers.AsNoTracking().Where(s => s.DriverId == id).FirstOrDefault(); DriverVm se = new DriverVm() { DriverVmId = item.DriverId, Name = item.Name, Address = item.Address, Mobile = item.Mobile, LicenseNumber = item.LicenseNumber, }; return(View(se)); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <DriverVm> GetDriverByUserName(string name) { BudAkutenUsers driverUser = await idctx.Users.Where(p => p.UserName == name). Select(d => new BudAkutenUsers { Email = d.Email, StreetAdress = d.StreetAdress, ZipCode = d.ZipCode, City = d.City, PhoneNumber = d.PhoneNumber, UserName = d.UserName, Image = d.Image, Id = d.Id }) .SingleOrDefaultAsync(); DriverVm driverVm = await appctx.Driver.Where(p => p.AspNetUsersId == driverUser.Id). Select(d => new DriverVm { Description = d.Description, A = d.A, B = d.B, C = d.C, CE = d.Ce, D = d.D, FirstName = d.FirstName, LastName = d.LastName }) .SingleOrDefaultAsync(); driverVm.Email = driverUser.Email; driverVm.StreetAdress = driverUser.StreetAdress; driverVm.ZipCode = driverUser.ZipCode; driverVm.City = driverUser.City; driverVm.PhoneNumber = driverUser.PhoneNumber; driverVm.UserName = driverUser.UserName; driverVm.Image = driverUser.Image; return(driverVm); }
public IActionResult UpdateDriver(DriverVm d) { if (HttpContext.Session.GetString("UserRole") == "1") { Driver di = new Driver() { DriverId = d.DriverVmId, Name = d.Name, Address = d.Address, LicenseNumber = d.LicenseNumber, Mobile = d.Mobile }; _context.Drivers.Update(di); _context.SaveChanges(); return(View()); } else { return(RedirectToAction("Index", "Home")); } }
public IActionResult DeleteDriver(DriverVm se) { _context.Drivers.Remove(_context.Drivers.AsNoTracking().Where(s => s.DriverId == se.DriverVmId).FirstOrDefault()); _context.SaveChanges(); return(RedirectToAction("DriverList")); }