public ActionResult Create(Client client)
 {
     client.Stylist = _db.Stylists.FirstOrDefault(stylist => stylist.StylistId == client.StylistId);
     _db.Clients.Add(client);
     _db.SaveChanges();
     return(RedirectToAction("Index", new { id = client.StylistId }));
 }
Example #2
0
 public ActionResult Create(Client client)
 {
     _db.Clients.Add(client);
     _db.SaveChanges();
     System.Console.WriteLine(client.StylistId);
     return(RedirectToAction("Details", "Stylists", new { id = client.StylistId }));
 }
 public ActionResult Create(Client client, int id)
 {
     client.StylistId = id;
     _db.Clients.Add(client);
     _db.SaveChanges();
     return(RedirectToAction("Index", "Stylists"));
 }
Example #4
0
 public ActionResult Create(Stylist stylist)
 {
     stylist.HireDate = DateTime.Now;
     _db.Stylists.Add(stylist);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #5
0
        public ActionResult Create(Appointment appointment)
        {
            List <Appointment> appointments = _db.Appointments.Where(app => app.StylistId == appointment.StylistId).ToList();
            bool flag = false;

            for (int i = 1; i < appointments.Count; i++)
            {
                if ((appointment.Time.Add(new TimeSpan(-1, 0, 0)) <= appointments[i].Time) && (appointment.Time.Add(new TimeSpan(1, 0, 0)) > appointments[i].Time))
                {
                    flag = true;
                    break;
                }
            }
            ViewBag.Failed = false;
            if (flag)
            {
                ViewBag.Failed = true;
                Stylist       currentStylist = _db.Stylists.FirstOrDefault(stylist => stylist.StylistId == appointment.StylistId);
                List <Client> clients        = _db.Clients.Where(client => client.StylistId == appointment.StylistId).ToList();
                ViewBag.ClientId = new SelectList(clients, "ClientId", "Name");
                ViewBag.Stylist  = currentStylist;
                return(View("Create"));
            }
            _db.Appointments.Add(appointment);
            _db.SaveChanges();
            return(RedirectToAction("Index", new { id = appointment.StylistId }));
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            var thisClient = _db.Clients.FirstOrDefault(clients => clients.ClientId == id);

            _db.Clients.Remove(thisClient);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
 public ActionResult Create(Stylist stylist)
 {
     if (stylist.Name != null)
     {
         _db.Stylists.Add(stylist);
         _db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Example #8
0
 public ActionResult Create(Client client)
 {
     if (client.StylistId != 0)
     {
         _db.Clients.Add(client);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("NullStylist"));
 }
Example #9
0
        public ActionResult Create(Client client)
        {
            Stylist foundStylist = _db.Stylists.FirstOrDefault(stylist => stylist.StylistId == client.StylistId);

            foundStylist.Clients.Add(client);
            _db.Clients.Add(client);
            _db.Entry(foundStylist).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #10
0
 public ActionResult Create(Stylist stylist, List <int> SpecialtyIds)
 {
     db.Stylists.Add(stylist);
     foreach (int specialtyId in SpecialtyIds)
     {
         StylistSpecialty newStylistSpecialty = new StylistSpecialty(specialtyId, stylist.StylistId);
         db.StylistSpecialties.Add(newStylistSpecialty);
     }
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #11
0
 public ActionResult Create(Client client, List <int> StylistIds)
 {
     db.Clients.Add(client);
     foreach (int stylistId in StylistIds)
     {
         StylistClient newStylistClient = new StylistClient(client.ClientId, stylistId);
         db.StylistClients.Add(newStylistClient);
     }
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Stylist stylist)
 {
     if (ModelState.IsValid)
     {
         DateTime now = DateTime.Now;
         stylist.HireDate = now;
         _db.Stylists.Add(stylist);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(stylist));
 }
        public ActionResult Create(Appointment appointment)
        {
            HashSet <Appointment> appointments = _db.Appointments.Where(x => x.StylistId == appointment.StylistId).ToHashSet();

            if (appointment.IsAbleToSchedule(appointments))
            {
                _db.Appointments.Add(appointment);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View("Error", "There is a time conflict for this time and stylist"));
        }
 public ActionResult Create(Stylist stylist)
 {
     try
     {
         _db.Stylists.Add(stylist);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Create(Stylist stylist)
 {
     if (stylist.Name == null)
     {
         System.Console.WriteLine("Null stylist name!");
     }
     else
     {
         _db.Stylists.Add(stylist);
         _db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Example #16
0
 public ActionResult Create(Client client)
 {
     foreach (Client clientExist in _db.Clients)
     {
         if (clientExist.FirstName == client.FirstName && clientExist.LastName == client.LastName)
         {
             return(RedirectToAction("Details", "Stylists", new { id = clientExist.StylistId }));
         }
     }
     _db.Clients.Add(client);
     _db.SaveChanges();
     return(RedirectToAction("Details", "Stylists", new { id = client.StylistId }));
 }
Example #17
0
 public ActionResult Create(Client client)
 {
     try
     {
         _db.Clients.Add(client);
         _db.SaveChanges();
         return(RedirectToAction("Details", "Stylists", new { id = client.StylistId }));
     }
     catch
     {
         return(RedirectToAction("Index", "Stylists"));
     }
 }
Example #18
0
 public ActionResult Create(Stylist stylist)
 {
     foreach (Stylist stylistUnique in _db.Stylists)
     {
         if (stylistUnique.FirstName == stylist.FirstName && stylistUnique.LastName == stylist.LastName && stylistUnique.Speciality == stylist.Speciality)
         {
             return(RedirectToAction("Index"));
         }
     }
     _db.Stylists.Add(stylist);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #19
0
 public ActionResult Create(Client client, int StylistId)
 {
     if (StylistId != 0)
     {
         _db.Clients.Add(client);
         _db.StylistClient.Add(new StylistClient()
         {
             StylistId = StylistId, ClientId = client.ClientId
         });
         _db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Appointment appointment)
 {
     foreach (Appointment appointmentExist in _db.Appointments)
     {
         if (appointmentExist.Time == appointment.Time)
         {
             return(RedirectToAction("Details", "Clients", new { id = appointment.ClientId }));
         }
     }
     _db.Appointments.Add(appointment);
     _db.SaveChanges();
     return(RedirectToAction("Details", "Clients", new { id = appointment.ClientId }));
 }
Example #21
0
 public ActionResult Create(Client client)
 {
     try
     {
         _db.Clients.Add(client);
         _db.SaveChanges();
     }
     catch (DbUpdateException e)
     {
         TempData["ErrorMessage"] = "The Client phone number already exists in the data. Please check again.";
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Stylist stylist)
 {
     try
     {
         _db.Stylists.Add(stylist);
         _db.SaveChanges();
     }
     catch (DbUpdateException e)
     {
         TempData["ErrorMessage"] = "The Name of Stylist already exists in the data. Please check again.";
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult Create(Client client)
        {
            if (client.Name == null)
            {
                System.Console.WriteLine("Null client!");
            }
            else
            {
                _db.Clients.Add(client);
                _db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Client client, int StylistId)
 {
     _db.Clients.Add(client);
     if (StylistId != 0)
     {
         _db.StylistClient.Add(new StylistClient()
         {
             StylistId = StylistId, ClientId = client.ClientId
         });
     }
     _db.SaveChanges();
     // return RedirectToAction("Index");
     // return RedirectToAction("Details", "Stylists", new {id = StylistId});
     return(RedirectToAction("Index"));
 }
Example #25
0
        public ActionResult Create(Client newClient)
        {
            Console.WriteLine(newClient.ClientName);
            if (ModelState.IsValid)
            {
                _db.Clients.Add(newClient);
                _db.SaveChanges();
                return(RedirectToAction("Index", "Stylist"));
            }
            else
            {
                return(RedirectToAction("Create", "Client"));
            }

            // most likely will redirect them back to index
        }
 public ActionResult Create(Stylist newStylist)
 {
     _db.Stylists.Add(newStylist);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
     // will mostlikely redirect to some other action or url.
 }
Example #27
0
 public ActionResult Create(Client client)
 {
     if (ModelState.IsValid)
     {
         string savedType = Enum.GetName(typeof(ClientState), client.ClientState);
         _db.Clients.Add(client);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else if (!ModelState.IsValid)
     {
         string savedType = Enum.GetName(typeof(ClientState), client.ClientState);
         ViewBag.StylistId = new SelectList(_db.Stylists, "StylistId", "StylistName");
         return(View());
     }
     return(View(client));
 }
Example #28
0
        public ActionResult Create(Appointment appointment)
        {
            List <Appointment> app = _db.Appointments.Where(appointments => appointments.AppointmentTime == appointment.AppointmentTime &
                                                            appointments.AppointmentDate == appointment.AppointmentDate &
                                                            appointments.ClientId == appointment.ClientId).ToList();

            // // ViewBag.data = app;
            // Console.WriteLine(ViewBag.data.Count + " ViewBag.data");
            if (app.Count == 0)
            {
                _db.Appointments.Add(appointment);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.data     = app;
                ViewBag.ClientId = new SelectList(_db.Clients, "ClientId", "ClientName");
                return(View("Create"));
            }
        }
 public ActionResult Create(Client client)
 {
     _db.Clients.Add(client);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #30
0
 public IActionResult Create(Stylist stylist)
 {
     db.Stylists.Add(stylist);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }