public Driver AddNewUser(Driver driver) { if (driver.PhoneNumber > 0) { try { if (driverIsExisted(driver.Username)) { driver.LoginErrorMessage = "Username or email have been used"; } else { driver = db.Drivers.Add(driver); db.SaveChanges(); } } catch (DbUpdateException) { driver.LoginErrorMessage = "Username or email have been used"; return(driver); } catch (DbEntityValidationException) { driver.LoginErrorMessage = "Can't be blank any field"; return(driver); } } else { driver.LoginErrorMessage = "Phone must be number"; } return(driver); }
//ID auto incre and this method return BookingLot which already added public BookingLot AddNewBookingLot(String driverId, DateTime entryTime) { BookingLot dto = new BookingLot { DriverID = driverId, EntryDateTime = entryTime, }; dto = db.BookingLots.Add(dto); db.SaveChanges(); return(dto); }
public BookingLotDetail AddNewBookingLotDetail(String hostId, String lotId, int blId, double price, int status) { BookingLotDetail dto = new BookingLotDetail { HostID = hostId, LotID = lotId, BookingLotID = blId, UnitPrice = price, status = status, }; dto = db.BookingLotDetails.Add(dto); db.SaveChanges(); return(dto); }
public void updateAvailableLot(String LoHID, bool available) { db.LotHosts.Where(lh => lh.LoHID == LoHID).FirstOrDefault().Available = available; db.SaveChanges(); }