Пример #1
0
        public ActionResult Create(
            [Bind(Include = "LastName,FirstName,PhoneNumber")] Customer customer,
            string preferredBarber)
        {
            if (ModelState.IsValid)
            {
                // Incoming customer begins waiting now
                //
                customer.ArrivalTime = DateTime.Now;
                customer.served      = false;

                var barbers = db.Barbers.ToList();

                foreach (var barber in barbers)
                {
                    if (string.Equals(preferredBarber, barber.Name))
                    {
                        customer.PreferredBarber = barber;
                    }
                }

                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Пример #2
0
        public IActionResult Create(MasterViewModel master)
        {
            if (ModelState.IsValid)
            {
                var createdMaster = new List <Master>();
                var error         = new List <Error>();

                try
                {
                    createdMaster.Add(_crudService.Create(master));
                    User user = new User {
                        Phone = master.Phone, Password = master.Password, FullName = master.FullName, RoleId = userId
                    };
                    _context.Users.Add(user);
                    _context.SaveChanges();
                }
                catch (ServiceOperationException exception)
                {
                    ViewBag.Error = ErrorFactory.IdentifyExceptionByType(exception).Description;
                    return(View(master));
                }

                return(RedirectToAction("Get", "MasterServices", new { masterId = master.Id }));
            }
            return(View(master));
        }
Пример #3
0
        public void UpdateAvailable(int id)
        {
            var barber = m_Context.Barbers.Where(barber => barber.Id == id).FirstOrDefault();

            if (barber != null)
            {
                barber.Available = !barber.Available;
            }

            m_Context.Barbers.Update(barber);
            m_Context.SaveChanges();
        }
Пример #4
0
 //Update
 public void Update(Service service)
 {
     _context.Entry(service).State = EntityState.Modified;
     _context.SaveChanges();
 }
Пример #5
0
 //Update
 public void Update(Customer customer)
 {
     _context.Entry(customer).State = EntityState.Modified;
     _context.SaveChanges();
 }
 //Update
 public void Update(Scheduling scheduling)
 {
     _context.Entry(scheduling).State = EntityState.Modified;
     _context.SaveChanges();
 }
 public Appointment Store(Appointment appointment)
 {
     db.Appointments.Add(appointment);
     db.SaveChanges();
     return(appointment);
 }
 public void Commit()
 {
     context.SaveChanges();
 }
Пример #9
0
 //Update
 public void Update(User user)
 {
     _context.Entry(user).State = EntityState.Modified;
     _context.SaveChanges();
 }