public void Delete(lib.Customer customer)
        {
            var entity = _dbContext.Customer.First(c => c.FirstName.Equals(customer.FirstName) && c.LastName.Equals(customer.LastName));

            _dbContext.Customer.Remove(entity);
            _dbContext.SaveChanges();
        }
Example #2
0
        public void Add(string t)
        {
            Tag tag = new Tag
            {
                term = t.ToLower()
            };

            _context.Tags.Add(tag);
            _context.SaveChanges();
        }
Example #3
0
        public void Update(lib.Location location)
        {
            var entity = _dbContext.Location
                         .First(s => s.LocationId == location.Id);

            foreach (var item in location.Inventory.Keys)
            {
                entity.Inventory.First(i => i.ProductId == item.ProductId).Amount = location.Inventory[item];
            }
            _dbContext.SaveChanges();
        }
Example #4
0
        public int Add(d.Review newReview)
        {
            var entity = new Review
            {
                DoctorId = newReview.DoctorId,
                UserId   = newReview.UserId,
                Rating   = newReview.Rating,
                Review1  = newReview.Content
            };

            _context.Reviews.Add(entity);
            _context.SaveChanges();
            return(entity.ReviewId);
        }
Example #5
0
        public int Add(d.Booking newBooking)
        {
            var entity = new Booking
            {
                Date        = newBooking.Date,
                DoctorId    = newBooking.DoctorId,
                PatientId   = newBooking.UserId,
                Description = newBooking.Description
            };

            _context.Bookings.Add(entity);
            _context.SaveChanges();
            return(entity.BookingId);
        }
Example #6
0
        public int Add(d.User newUser)
        {
            var entity = new User
            {
                Username  = newUser.UserName,
                Pass      = newUser.PassWord,
                FirstName = newUser.FirstName,
                LastName  = newUser.LastName,
                Email     = newUser.Email,
                City      = newUser.City.ToLower(),
                State     = newUser.State,
                Phone     = newUser.Phone
            };

            _context.Users.Add(entity);
            _context.SaveChanges();
            return(entity.UserId);
        }
Example #7
0
        public int Add(d.Doctor newDoctor)
        {
            var entity = new Doctor
            {
                Username      = newDoctor.UserName,
                Pass          = newDoctor.PassWord,
                FirstName     = newDoctor.FirstName,
                LastName      = newDoctor.LastName,
                Email         = newDoctor.Email,
                City          = newDoctor.City.ToLower(),
                State         = newDoctor.State,
                Bio           = newDoctor.Bio,
                ExpYears      = newDoctor.Exp,
                Fee           = newDoctor.Fee,
                Phone         = newDoctor.Phone,
                Rating        = 0,
                Consultations = 0,
                DoctorType    = newDoctor.DoctorType
            };

            _context.Doctors.Add(entity);
            _context.SaveChanges();
            var doc     = _context.Doctors.First(d => d.Username == entity.Username);
            var cityTag = _context.Tags.First(t => t.term == doc.City.ToLower());
            var city    = new DoctorTag {
                doctorId = doc.DoctorId, tagId = cityTag.tagId
            };
            var stateTag = _context.Tags.First(t => t.term == doc.State.ToLower());
            var state    = new DoctorTag {
                doctorId = doc.DoctorId, tagId = stateTag.tagId
            };
            var typeTag = _context.Tags.First(t => t.term == doc.DoctorType.ToLower());
            var type    = new DoctorTag {
                doctorId = doc.DoctorId, tagId = typeTag.tagId
            };

            _context.DoctorTags.Add(city);
            _context.SaveChanges();
            _context.DoctorTags.Add(type);
            _context.SaveChanges();
            _context.DoctorTags.Add(state);
            _context.SaveChanges();
            return(entity.DoctorId);
        }
 public void Save()
 {
     _dbContext.SaveChanges();
 }