Пример #1
0
        //add lease to db
        public static void Add(Lease lease)
        {
            var db = new MarinaEntities();

            db.Leases.Add(lease);
            db.SaveChanges();
        }
Пример #2
0
        public static void Add(Customer auth) //add new customer
        {
            var db = new MarinaEntities();

            db.Customers.Add(auth);
            db.SaveChanges();
        }
Пример #3
0
 public void LeaseSlip(Lease newLease)
 {
     using (var db = new MarinaEntities())
     {
         db.Leases.Add(newLease);
         db.SaveChanges();
     }
 }
Пример #4
0
 // Add a newly registered customer to DB
 public static void Add(Customer cust)
 {
     using (var db = new MarinaEntities())
     {
         db.Customers.Add(cust);
         db.SaveChanges();
     }
 }
Пример #5
0
 // update customer in db.
 public static void Update(Customer cust)
 {
     using (var db = new MarinaEntities())
     {
         var custFromContext = db.Customers
                               .SingleOrDefault(c => c.ID == cust.ID);
         custFromContext.FirstName = cust.FirstName;
         custFromContext.LastName  = cust.LastName;
         custFromContext.City      = cust.City;
         custFromContext.Phone     = cust.Phone;
         db.SaveChanges();
     }
 }
Пример #6
0
        public static void EnrollService(LeaseDTO LeaseToDB)
        {
            var db = new MarinaEntities();

            var sc = new Lease
            {
                SlipID     = int.Parse(LeaseToDB.SlipID),
                CustomerID = int.Parse(LeaseToDB.CustomerID)
            };

            //add lease object to the context and save changes in the database
            db.Leases.Add(sc);
            db.SaveChanges();
        }
Пример #7
0
        /// <summary>
        /// Static method handles adding a new authentication object to the DB
        /// </summary>
        /// <param name="auth">The authentication object is a DTO object</param>
        public static void AddAuthentication(AuthenticationDTO auth)
        {
            //use the context to add a new authentication object
            var db = new MarinaEntities();

            //assign from dto object to the entity object
            var authFromContext = new Customer
            {
                FirstName = auth.FirstName,
                LastName  = auth.LastName,
                Phone     = auth.Phone,
                City      = auth.City
            };

            db.Customers.Add(authFromContext);
            db.SaveChanges();
        }
Пример #8
0
        /// <summary>
        /// Static method handles the update of an existing authentication object
        /// </summary>
        /// <param name="auth">The authentication object as a DTO</param>
        public static void UpdateAuthentication(AuthenticationDTO auth)
        {
            //use the context to update an existing record
            var id = Convert.ToInt32(auth.Id);
            var db = new MarinaEntities();

            //we need to get an authentication object from the context
            //so that we can update it with values from the dto passed in
            var authFromContext = db.Customers.SingleOrDefault(a => a.ID == id);

            authFromContext.FirstName = auth.FirstName;
            authFromContext.Phone     = auth.Phone;
            authFromContext.City      = auth.City;

            //save changes--no need to add the object back to the context as the context
            //already has it
            db.SaveChanges();
        }
        /// <summary>
        /// Adds new lease to database
        /// </summary>
        /// <param name="slipID"></param>
        /// <param name="custID"></param>
        /// Code written by Julie Tran
        /// Modifed by Tony Li
        //Last Modified Febuary 9 2021
        public static void Add(int slipID, int custID)
        {
            var db         = new MarinaEntities();
            var slipEntity = (from slip in db.Slips
                              where slip.ID == slipID
                              select slip
                              ).SingleOrDefault();

            var customerEntity = (from cust in db.Customers
                                  where cust.ID == custID
                                  select cust).SingleOrDefault();
            var newLease = new Lease
            {
                Slip     = slipEntity,
                Customer = customerEntity
            };

            db.Leases.Add(newLease);
            db.SaveChanges();
        }