// find slip id public static Slip FindSlip(int id) { var db = new MarinaEntities(); var slip = db.Slips.SingleOrDefault(s => s.ID == id); return(slip); }
public static void Add(Authentication auth) { var db = new MarinaEntities(); db.Authentications.Add(auth); db.SaveChanges(); }
// find dock id public static Dock Find(int ID) { var db = new MarinaEntities(); var docks = db.Docks.FirstOrDefault(d => d.ID == ID); return(docks); }
public static Authentication Find(int customerID) { var db = new MarinaEntities(); var auth = db.Authentications. SingleOrDefault(a => a.CustomerID == customerID); return(auth); }
// retrieve all lease info by customer id public static ICollection <Lease> GetLeasesByCustomerID(int ID) { var db = new MarinaEntities(); List <Lease> leases = (from lease in db.Leases where lease.CustomerID == ID select lease).ToList(); return(leases); }
// retreive slips that are not leased by dock id public static List <Slip> getAvailableSlipByDock(int id) { var db = new MarinaEntities(); List <Slip> slips = (from slip in db.Slips where (!(from lease in db.Leases select lease.SlipID).Contains(slip.ID)) && slip.DockID == id select slip).ToList(); return(slips); }
public static void Update(Authentication auth) { var db = new MarinaEntities(); var authFromContext = db.Authentications.SingleOrDefault(a => a.ID == auth.ID); authFromContext.Username = auth.Username; authFromContext.Password = auth.Password; authFromContext.Customer.FirstName = auth.Customer.FirstName; authFromContext.Customer.LastName = auth.Customer.LastName; authFromContext.Customer.Phone = auth.Customer.Phone; authFromContext.Customer.City = auth.Customer.City; db.SaveChanges(); }
// retrieve all dock info public IList GetAllListItems() { var db = new MarinaEntities(); var docks = db.Docks.Select(dk => new { ID = dk.ID, Name = dk.Name, WaterService = dk.WaterService, ElectricalService = dk.ElectricalService }).ToList(); return(docks); }
// retrieve all lease info public static IList GetAllLeases(int ID) { var db = new MarinaEntities(); var leases = db.Leases.Select(l => new { ID = l.ID, SlipID = l.SlipID, CustomerID = l.CustomerID }).ToList(); return(leases); }
// retrieve all slip info public IList GetAllSlipsListItems() { var db = new MarinaEntities(); var slips = db.Slips.Select(sp => new { ID = sp.ID, Width = sp.Width, Length = sp.Length, DockId = sp.DockID }).ToList(); return(slips); }
public static CustomerDTO Authenticate(string username, string password) { CustomerDTO dto = null; var db = new MarinaEntities(); var auth = db.Authentications. FirstOrDefault(a => a.Username == username && a.Password == password); if (auth != null) // authentication passsed { dto = new CustomerDTO { ID = auth.Customer.ID, FullName = $"{auth.Customer.FirstName} {auth.Customer.LastName}" }; } return(dto); }