示例#1
0
        public ActionResult Edit(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.AppointmentId != appointments[i].AppointmentId) && (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;
                Appointment    thisAppointment = _db.Appointments.FirstOrDefault(app => app.AppointmentId == appointment.AppointmentId);
                List <Stylist> stylists        = _db.Stylists.ToList();
                List <Client>  clients         = _db.Clients.ToList();
                ViewBag.StylistId = new SelectList(stylists, "StylistId", "Name");
                ViewBag.ClientId  = new SelectList(clients, "ClientId", "Name");
                return(View("Edit", thisAppointment));
            }
            else
            {
                var local = _db.Appointments
                            .Local
                            .FirstOrDefault(app => app.AppointmentId.Equals(appointment.AppointmentId));
                _db.Entry(local).State       = EntityState.Detached;
                _db.Entry(appointment).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Details", new { id = appointment.AppointmentId }));
            }
        }
示例#2
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"));
        }
示例#3
0
        public ActionResult Edit(Client client, List <int> StylistIds)
        {
            db.Entry(client).State = EntityState.Modified;
            var clientMatchesInJoinTable = db.StylistClients.Where(entry => entry.ClientId == client.ClientId).ToList();

            foreach (var stylist in clientMatchesInJoinTable)
            {
                int stylistId = stylist.StylistId;
                var joinEntry = db.StylistClients
                                .Where(entry => entry.StylistId == stylistId)
                                .Where(entry => entry.ClientId == client.ClientId);
                foreach (var entry in joinEntry)
                {
                    db.StylistClients.Remove(entry);
                }
            }

            foreach (var id in StylistIds)
            {
                Stylist       stylist          = db.Stylists.FirstOrDefault(otherEntry => otherEntry.StylistId == id);
                StylistClient newStylistClient = new StylistClient(client.ClientId, stylist.StylistId);
                db.StylistClients.Add(newStylistClient);
            }

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(Specialty specialty, List <int> StylistIds)
        {
            db.Entry(specialty).State = EntityState.Modified;
            var specialtyMatchesInJoinTable = db.StylistsSpecialties.Where(entry => entry.SpecialtyId == specialty.SpecialtyId).ToList();

            foreach (var stylist in specialtyMatchesInJoinTable)
            {
                int stylistId = stylist.StylistId;
                var joinEntry = db.StylistsSpecialties
                                .Where(entry => entry.StylistId == stylistId)
                                .Where(entry => entry.SpecialtyId == specialty.SpecialtyId);
                foreach (var entry in joinEntry)
                {
                    db.StylistsSpecialties.Remove(entry);
                }
            }
            foreach (var id in StylistIds)
            {
                Stylist          stylist             = db.Stylists.FirstOrDefault(_ => _.StylistId == id);
                StylistSpecialty newStylistSpecialty = new StylistSpecialty(stylist.StylistId, specialty.SpecialtyId);
                db.StylistsSpecialties.Add(newStylistSpecialty);
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
        public ActionResult Edit(Client client)
        {
            _db.Entry(client).State = EntityState.Modified;
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(Appointment appointment)
        {
            Appointment model = appointment;

            _db.Entry(appointment).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(Stylist stylist)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(stylist).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(stylist));
 }
 public ActionResult Edit(Stylist stylist)
 {
     try
     {
         _db.Entry(stylist).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Details", new { id = stylist.StylistId }));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Edit(Client client, int StylistId)
 {
     if (StylistId != 0)
     {
         _db.StylistClient.Add(new StylistClient()
         {
             StylistId = StylistId, ClientId = client.ClientId
         });
     }
     _db.Entry(client).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#10
0
 public ActionResult Edit(Client client)
 {
     try
     {
         _db.Entry(client).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Details", new { id = client.ClientId }));
     }
     catch
     {
         return(RedirectToAction("Index", "Stylists"));
     }
 }
示例#11
0
 public ActionResult Edit(Client client)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(client).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else if (!ModelState.IsValid)
     {
         ViewBag.StylistId = new SelectList(_db.Stylists, "StylistId", "StylistName");
         return(View());
     }
     return(View(client));
 }
示例#12
0
        public ActionResult Edit(Stylist stylist, List <int> SpecialtyIds, List <int> ClientIds)
        {
            db.Entry(stylist).State = EntityState.Modified;
            var stylistMatchesInJoinTable = db.StylistSpecialties.Where(entry => entry.StylistId == stylist.StylistId).ToList();

            foreach (var specialty in stylistMatchesInJoinTable)
            {
                int specialtyId = specialty.SpecialtyId;
                var joinEntry   = db.StylistSpecialties
                                  .Where(entry => entry.SpecialtyId == specialtyId)
                                  .Where(entry => entry.StylistId == stylist.StylistId);
                foreach (var entry in joinEntry)
                {
                    db.StylistSpecialties.Remove(entry);
                }
            }

            foreach (var id in SpecialtyIds)
            {
                Specialty        specialty           = db.Specialties.FirstOrDefault(otherEntry => otherEntry.SpecialtyId == id);
                StylistSpecialty newStylistSpecialty = new StylistSpecialty(specialty.SpecialtyId, stylist.StylistId);
                db.StylistSpecialties.Add(newStylistSpecialty);
            }

            var stylistMatchesClients = db.StylistClients.Where(entry => entry.StylistId == stylist.StylistId).ToList();

            foreach (var client in stylistMatchesClients)
            {
                int clientId  = client.ClientId;
                var joinEntry = db.StylistClients
                                .Where(entry => entry.ClientId == clientId)
                                .Where(entry => entry.StylistId == stylist.StylistId);
                foreach (var entry in joinEntry)
                {
                    db.StylistClients.Remove(entry);
                }
            }

            foreach (var id in ClientIds)
            {
                Client        client           = db.Clients.FirstOrDefault(newEntry => newEntry.ClientId == id);
                StylistClient newStylistClient = new StylistClient(client.ClientId, stylist.StylistId);
                db.StylistClients.Add(newStylistClient);
            }

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#13
0
 public ActionResult Edit(Client client, int StylistId)
 {
     if (StylistId != 0)
     {
         var returnedJoin = _db.ClientStylist
                            .Any(join => join.ClientId == client.ClientId && join.StylistId == StylistId);
         if (!returnedJoin)
         {
             _db.ClientStylist.Add(new ClientStylist()
             {
                 StylistId = StylistId, ClientId = client.ClientId
             });
         }
     }
     _db.Entry(client).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Details", "Clients", new { id = client.ClientId }));
 }
 public ActionResult Edit(Stylist stylist)
 {
     _db.Entry(stylist).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index")); //keep an eye on this
 }
 public ActionResult Edit(Stylist stylist, int ClientId)
 {
     _db.Entry(stylist).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Details", "Stylists", new { id = stylist.StylistId }));
 }
 public ActionResult Edit(Customer customer)
 {
     _db.Entry(customer).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#17
0
 public ActionResult Edit(Review review)
 {
     _db.Entry(review).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#18
0
 public IActionResult Edit(Stylist stylist)
 {
     db.Entry(stylist).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#19
0
 public ActionResult Edit(Client client)
 {
     _db.Entry(client).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Details", "Clients", new { id = client.ClientId }));
 }