public ActionResult Edit([Bind(Include = "Id,Tutor,Student,DayName,TimeOfDay")]
                                 TutorScheduleViewModel tutorSchedule)
        {
            if (ModelState.IsValid)
            {
                var modifiedSchedule = _db.TutorSchedules.Find(tutorSchedule.Id);
                if (modifiedSchedule != null)
                {
                    using (var context = new SenecaContext())
                    {
                        var             sqlString = "SELECT Tutor_Id FROM TutorSchedule WHERE Id = " + tutorSchedule.Id;
                        var             tutorId   = context.Database.SqlQuery <string>(sqlString).FirstOrDefault();
                        ApplicationUser tutor     = _db.Users.Find(tutorId);
                        modifiedSchedule.Tutor = tutor;

                        sqlString = "SELECT Student_Id FROM TutorSchedule WHERE Id = " + tutorSchedule.Id;
                        var     studentId = context.Database.SqlQuery <int>(sqlString).FirstOrDefault();
                        Student student   = _db.Students.Find(studentId);
                        modifiedSchedule.Student = student;
                    }

                    modifiedSchedule.DayOfWeekIndex      = GetDayOfWeekIndex(tutorSchedule.DayName);
                    modifiedSchedule.MinutesPastMidnight = ConvertToMinutesPastMidnight(tutorSchedule.TimeOfDay);
                    _db.Entry(modifiedSchedule).State    = EntityState.Modified;
                    _db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(tutorSchedule));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "Id,name")] School school)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(school).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(school));
 }
 public ActionResult Edit([Bind(Include = "Id,Name")] DocumentType documentType)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(documentType).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(documentType));
 }
示例#4
0
 public ActionResult Edit([Bind(Include = "Id,firstName,lastName,title,workPhone,cellPhone,eMail")] Staff staff)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(staff).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(staff));
 }
示例#5
0
 public ActionResult Edit([Bind(Include = "Id,Name,Address,MainPhone,Fax,Email,ContactName,ContactEmail,ContactPhone,BoxWeight,ProviderNote")] HfedProvider hfedProvider)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hfedProvider).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hfedProvider));
 }
示例#6
0
 public ActionResult Edit([Bind(Include = "Id,Name")] TipsCategory tipsCategory)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(tipsCategory).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tipsCategory));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Address,MainPhone,LocationNote")] HfedLocation hfedLocation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hfedLocation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hfedLocation));
 }
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Address,CityStateZip,HomePhone,CellPhone,Email")] Volunteer volunteer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(volunteer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(volunteer));
 }
 public ActionResult Edit([Bind(Include = "Id,name")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(location));
 }
示例#10
0
 public ActionResult Edit([Bind(Include = "Id,UserName,FirstName,LastName,DateTime,Status")] Login login)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(login).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(login));
 }
示例#11
0
 public ActionResult Edit([Bind(Include = "Id")] AssociateTutor associateTutor)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(associateTutor).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(associateTutor));
 }
示例#12
0
        public ActionResult Edit([Bind(Include = "Id,Tutor,Student,DayName,TimeOfDay")]
                                 TutorScheduleViewModel tutorSchedule)
        {
            if (ModelState.IsValid)
            {
                var modifiedSchedule = _db.TutorSchedules.Find(tutorSchedule.Id);
                if (modifiedSchedule != null)
                {
                    using (var context = new SenecaContext())
                    {
                        var             sqlString = "SELECT Tutor_Id FROM TutorSchedule WHERE Id = " + tutorSchedule.Id;
                        var             tutorId   = context.Database.SqlQuery <string>(sqlString).FirstOrDefault();
                        ApplicationUser tutor     = _db.Users.Find(tutorId);
                        modifiedSchedule.Tutor = tutor;
                        tutorSchedule.Tutor    = tutor;

                        sqlString = "SELECT Student_Id FROM TutorSchedule WHERE Id = " + tutorSchedule.Id;
                        var     studentId = context.Database.SqlQuery <int>(sqlString).FirstOrDefault();
                        Student student   = _db.Students.Find(studentId);
                        modifiedSchedule.Student = student;
                    }

                    modifiedSchedule.DayOfWeekIndex      = GetDayOfWeekIndex(tutorSchedule.DayName);
                    modifiedSchedule.MinutesPastMidnight = ConvertToMinutesPastMidnight(tutorSchedule.TimeOfDay);
                    _db.Entry(modifiedSchedule).State    = EntityState.Modified;
                    _db.SaveChanges();
                    if (modifiedSchedule.Student != null)
                    {
                        string msgText = "On " + DateTime.Now.ToShortDateString() + " "
                                         + modifiedSchedule.Tutor.FullName + " changed "
                                         + modifiedSchedule.Student.FirstName + " to "
                                         + tutorSchedule.DayName + " " + tutorSchedule.TimeOfDay;
                        Task <ActionResult> unused = new AccountController().EmailSheduleChange(modifiedSchedule.Tutor, msgText);
                    }

                    return(RedirectToAction("Index"));
                }
            }
            return(View(tutorSchedule));
        }