Exemple #1
0
        public HttpStatusCodeResult ReceiveClass(int ClassId)
        {
            try
            {
                string            tutorUsername     = User.Identity.GetUserName();
                string            UserId            = User.Identity.GetUserId();
                RegistrationClass RegistrationClass = db.RegistrationClasses.Include(s => s.Customer).SingleOrDefault(s => s.Id == ClassId);
                Customer          customer          = RegistrationClass.Customer;
                string            customerUsername  = UserManager.FindById(customer.UserId).UserName;
                Tutor             tutor             = db.Tutors.SingleOrDefault(s => s.UserId == UserId);
                RegistrationClass.Tutor  = tutor;
                RegistrationClass.Status = Enums.ClassStatus.WaitingForCustomerApproval;

                db.Entry(RegistrationClass).State = EntityState.Modified;
                db.SaveChanges();
                //send to tutor
                EmailSenderService.SendHtmlFormattedEmail(tutor.Email, "Yêu cầu nhận lớp mã số : " + RegistrationClass.Id,
                                                          EmailSenderService.PopulateBody(customer.FullName, tutor.FullName, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToTutor.html"));
                //send to customer
                EmailSenderService.SendHtmlFormattedEmail(customer.Email, "Yêu cầu nhận lớp",
                                                          EmailSenderService.PopulateBodyTutorEnrollClassNotificationToCustomer(customer.FullName, tutor, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToCustomer.html"));
                //send to admin
                EmailSenderService.SendHtmlFormattedEmail(AdminEmail, "Gia sư đăng kí nhận lớp",
                                                          EmailSenderService.PopulateBodyTutorEnrollClassNotificationToAdmin(customer, customerUsername, tutor, tutorUsername, RegistrationClass.Id.ToString(), "~/EmailTemplates/ClassTutorEnrollmentNotificationToAdmin.html"));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
 public ActionResult Edit([Bind(Include = "Id,FullName,HomeTown,Address,DateOfBirth,Email,PhoneNumber,Gender,IdentityNumber,University,MajorSubject,GraduationYear,Advantage,Degree,Image")] Tutor tutor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tutor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tutor));
 }
Exemple #3
0
        public JsonResult ActivateCustomer(int CustomerId)
        {
            try
            {
                Customer customer = db.Customers.SingleOrDefault(s => s.Id == CustomerId);
                if (!customer.IsActivate)
                {
                    customer.IsActivate = true;
                }
                db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                EmailSenderService.SendHtmlFormattedEmail(customer.Email, "Kích hoạt tài khoản", EmailSenderService.PopulateBody(customer.FullName, "~/EmailTemplates/ActivateAccountSuccess.html"));
            }
            catch (Exception ex)
            {
                return(Json(new { Status = "Error" }));
            }

            return(Json(new { Status = "OK" }));
        }
Exemple #4
0
        public ActionResult EditTutorInfo(HttpPostedFileBase Avatar, PrivateTutorOnline.Models.BindingModels.TutorBindingModel tutorInfo)
        {
            Tutor tutor = db.Tutors.Include(s => s.Grades).Include(s => s.Subjects).SingleOrDefault(s => s.Id == tutorInfo.Id);

            tutor.Subjects.Clear();
            tutor.Grades.Clear();
            db.Entry(tutor).State = EntityState.Modified;
            db.SaveChanges();
            tutor = db.Tutors.Include(s => s.Grades).Include(s => s.Subjects).SingleOrDefault(s => s.Id == tutorInfo.Id);
            if (tutor != null)
            {
                if (Avatar != null)
                {
                    tutor.Image = new byte[Avatar.ContentLength];
                    Avatar.InputStream.Read(tutor.Image, 0, Avatar.ContentLength);
                }
                tutor.FullName  = tutorInfo.FullName;
                tutor.City      = tutorInfo.City;
                tutor.District  = tutorInfo.District;
                tutor.Ward      = tutorInfo.Ward;
                tutor.Street    = tutorInfo.Street;
                tutor.Advantage = tutorInfo.Advantage;
                if (tutorInfo.DateOfBirth.HasValue)
                {
                    tutor.DateOfBirth = tutorInfo.DateOfBirth.Value;
                }
                tutor.Gender         = tutorInfo.Gender;
                tutor.Degree         = tutorInfo.Degree;
                tutor.Email          = tutorInfo.Email;
                tutor.GraduationYear = tutorInfo.GraduationYear;
                tutor.HomeTown       = tutorInfo.HomeTown;
                tutor.IdentityNumber = tutorInfo.IdentityNumber;
                tutor.MajorSubject   = tutorInfo.MajorSubject;
                tutor.PhoneNumber    = tutorInfo.PhoneNumber;
                tutor.University     = tutorInfo.UniversityName;
                if (tutorInfo.Subjects.Count > 0)
                {
                    tutor.Subjects = new List <Subject>();
                    foreach (int i in tutorInfo.Subjects)
                    {
                        tutor.Subjects.Add(db.Subjects.SingleOrDefault(s => s.Id == i));
                    }
                }
                if (tutorInfo.Grades.Count > 0)
                {
                    tutor.Grades = new List <Grade>();
                    foreach (int i in tutorInfo.Grades)
                    {
                        tutor.Grades.Add(db.Grades.SingleOrDefault(gr => gr.Id == i));
                    }
                }

                UserManager.SetEmail(User.Identity.GetUserId(), tutor.Email);
                db.Entry(tutor).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index", "Manage"));
            }
            else
            {
                return(View("Error"));
            }
        }