public void RemoveVolunteer(int volunteerId) { Volunteer = new Volunteer(); Volunteer = db.Volunteers.Find(volunteerId); Volunteer.CharityExamID = null; db.SaveChanges(); }
public void GetVolunteerInfo(int volunteerID) { Volunteer = new Volunteer(); Volunteer = db.Volunteers.Find(volunteerID); VolunteerID = Volunteer.VolunteerID; }
public ActionResult Register(FormCollection f) { string icap = f["inputCaptcha"]; if (icap == "") { Account acc = new Account(); acc.Email = f["email"]; acc.Password = f["password"]; acc.RoleID = int.Parse(f["role"]); Profile pro = new Profile(); pro.Firstname = f["firstname"]; pro.Lastname = f["lastname"]; pro.Gender = bool.Parse(f["gender"]); pro.DateOfBirth = DateTime.Parse(f["dateOfBirth"]); pro.PhoneNumber = f["phoneNumber"]; pro.Address = f["address"]; pro.DistrictID = int.Parse(f["district"]); TempData["acc"] = acc; TempData["pro"] = pro; TempData["emptyCaptcha"] = "Captcha rỗng"; return RedirectToAction("Register", "Account"); } else if (icap != "") { if (icap != Session["Captcha"].ToString()) { TempData["wrongCaptcha"] = "Kết quả sai"; return Redirect("Register"); } else if (icap == Session["Captcha"].ToString()) { Account acc = new Account(); acc.Email = f["email"]; acc.Password = f["password"]; acc.IsActive = false; acc.RoleID = int.Parse(f["role"]); db.Accounts.Add(acc); db.SaveChanges(); switch (acc.RoleID) { case 1: Candidate can = new Candidate(); can.AccountID = acc.AccountID; db.Candidates.Add(can); break; case 2: Charity cha = new Charity(); cha.AccountID = acc.AccountID; db.Charities.Add(cha); break; case 3: Sponsor sp = new Sponsor(); sp.AccountID = acc.AccountID; db.Sponsors.Add(sp); break; case 4: Volunteer vo = new Volunteer(); vo.AccountID = acc.AccountID; //vo.JobName = f["job"]; //vo.Description = f["des"]; db.Volunteers.Add(vo); break; } db.SaveChanges(); Profile pro = new Profile(); pro.AccountID = acc.AccountID; pro.Firstname = f["firstname"]; pro.Lastname = f["lastname"]; pro.Gender = bool.Parse(f["gender"]); pro.DateOfBirth = DateTime.Parse(f["dateOfBirth"]); pro.PhoneNumber = f["phoneNumber"]; pro.Address = f["address"]; pro.DistrictID = int.Parse(f["district"]); db.Profiles.Add(pro); db.SaveChanges(); acc.ProfileID = pro.ProfileID; db.SaveChanges(); Session.Clear(); //string strRandomCode = RandomCode(6); //string abc = null; //MailMessage loginInfo = new MailMessage(); //loginInfo.To.Add(acc.Email); //loginInfo.From = new MailAddress("TSMT<*****@*****.**>"); //loginInfo.Subject = "Confirm Your Registration"; //loginInfo.Body = "Hello. Mr/Mrs/Miss <b>" + acc.Profile.Lastname + " " + acc.Profile.Firstname + "</b> Welcome to TSMT. Thanks for your registration! Your confirmation code: <b>" + strRandomCode + "</b><br/><br/>Please click <a href=" + abc + ">here </a>to confirm registration"; ////loginInfo.Body = "Tên khách hàng: " + TBten.Text + "<br><br>Nhấp <a href=" + sss + ">vào đây</a> để xác nhận tài khoản "; //loginInfo.IsBodyHtml = true; //SmtpClient smtp = new SmtpClient(); //smtp.Host = "smtp.gmail.com"; //smtp.Port = 587; //smtp.EnableSsl = true; //smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "64689205"); //smtp.Send(loginInfo); } } return RedirectToAction("Index", "Home"); }