Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,FullName,HomeTown,Address,DateOfBirth,Email,PhoneNumber,Gender,IdentityNumber,University,MajorSubject,GraduationYear,Advantage,Degree,Image")] Tutor tutor)
        {
            if (ModelState.IsValid)
            {
                db.Tutors.Add(tutor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tutor));
        }
        public ActionResult SaveTutorInfo(HttpPostedFileBase Avatar, PrivateTutorOnline.Models.BindingModels.TutorBindingModel tutorInfo)
        {
            if (Avatar != null && Avatar.ContentLength > 0)
            {
                // extract only the fielname
                var fileName = Path.GetFileName(Avatar.FileName);
                // store the file inside ~/App_Data/uploads folder
                var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                Avatar.SaveAs(path);

                Tutor tutor = new Tutor();
                tutor.FullName       = tutorInfo.FullName;
                tutor.Address        = tutorInfo.Address;
                tutor.Advantage      = tutorInfo.Advantage;
                tutor.DateOfBirth    = tutorInfo.DateOfBirth;
                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;
                tutor.Image          = new byte[Avatar.ContentLength];
                Avatar.InputStream.Read(tutor.Image, 0, Avatar.ContentLength);
                tutor.Subjects = new List <Subject>();
                tutor.Grades   = new List <Grade>();
                foreach (int i in tutorInfo.Subjects)
                {
                    tutor.Subjects.Add(db.Subjects.SingleOrDefault(s => s.Id == i));
                }
                foreach (int i in tutorInfo.Grades)
                {
                    tutor.Grades.Add(db.Grades.SingleOrDefault(gr => gr.Id == i));
                }
                db.Tutors.Add(tutor);
                db.SaveChanges();
                return(View("Success"));
            }
            else
            {
                return(View("Error"));
            }
        }
Ejemplo n.º 4
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" }));
        }