public IEnumerable <Car> RestGetAllCars() { using (var context = new CarHireContext()) { return(context.Cars.ToList()); } }
public Car RestGetCarById(string vehicleId) { using (var context = new CarHireContext()) { Guid id; return(Guid.TryParse(vehicleId, out id) ? context.Cars.FirstOrDefault(c => c.VehicleId == id) : null); } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!this.ModelState.IsValid) { return(this.View(model)); } UserAccount user; using (var context = new CarHireContext()) { user = context.Users.FirstOrDefault(u => u.Email == model.Email); } SignInStatus result = (user != null) ? await this.SignInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, true) : await this.SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, true); // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true switch (result) { case SignInStatus.Success: return(this.RedirectToAction("Index", "Home")); case SignInStatus.LockedOut: return(this.View("Lockout")); case SignInStatus.RequiresVerification: return(this.RedirectToAction("SendCode", new { ReturnUrl = returnUrl, model.RememberMe })); case SignInStatus.Failure: default: this.ModelState.AddModelError("", "Invalid login attempt."); return(this.View(model)); } }
public void Repository(CarHireContext context) { this.Context = context; this.Dataset = context.Set <T>(); }
public CarRepository(CarHireContext dataContext) { this.Context = dataContext; base.Repository(this.Context); }
public StoreLocationRepo(CarHireContext dataContext) { this.Context = dataContext; base.Repository(this.Context); }