public static Customer Find(int customerId)
        {
            var db   = new MarinaEntities();
            var auth = db.Customers.SingleOrDefault(c => c.ID == customerId);

            return(auth);
        }
        public static void Add(Customer auth)
        {
            var db = new MarinaEntities();

            db.Customers.Add(auth);
            db.SaveChanges();
        }
        public static Slip Find(int dkId)
        {
            var db  = new MarinaEntities();
            var slp = db.Slips.SingleOrDefault(s => s.DockID == dkId);

            return(slp);
        }
        public static List <Slip> GetLeaseAll()
        {
            var db    = new MarinaEntities();
            var slips = db.Slips.ToList();

            return(slips);
        }
        public IList GetUnleasedSlip()
        {
            var db    = new MarinaEntities();
            var slips = db.Slips.Select(slp => new
                                        { id = slp.ID, width = slp.Width, lenght = slp.Length, dkId = slp.DockID }).ToList();

            return(slips);
        }
        public static void Update(Customer auth)
        {
            var db = new MarinaEntities();
            var authFromContext = db.Customers.SingleOrDefault(c => c.ID == auth.ID);

            authFromContext.FirstName = auth.FirstName;
            authFromContext.LastName  = auth.LastName;
            authFromContext.FirstName = auth.FirstName;
            authFromContext.LastName  = auth.LastName;
            authFromContext.City      = auth.City;
            authFromContext.Phone     = auth.Phone;
            db.SaveChanges();
        }
        public IList GetAllDocks()
        {
            var db    = new MarinaEntities();
            var docks = db.Docks.Select(dck => new
            {
                Id                 = dck.ID,
                name               = dck.Name,
                waterservice       = dck.WaterService,
                electricityservice = dck.ElectricalService
            }).ToList();

            return(docks);
        }
        public static CustomerDTO Authenticate(string firstname, string lastname)
        {
            CustomerDTO dto  = null;
            var         db   = new MarinaEntities();
            var         auth = db.Customers.SingleOrDefault
                                   (c => c.FirstName == firstname && c.LastName == lastname);

            if (auth != null)
            {
                // if the authentication is null the user is not a customer
                dto = new CustomerDTO
                {
                    ID       = auth.ID,
                    FullName = $"{auth.FirstName} {auth.LastName}",
                };
            }
            return(dto);
        }