public JsonResult CreateStaff(string kanjiName, string kanaName, string password, string generationno) { StaffDao staffDao = new StaffDao(); Staff staff = new Staff { kanjiName = kanjiName, kanaName = kanaName, generationno = generationno, password = password }; return(Json(staffDao.Create(staff))); }
public ActionResult Create(staff sta, HttpPostedFileBase photo) { GroupRoleDao grDao = new GroupRoleDao(); StaffDao dao = new StaffDao(); if (ModelState.IsValid) { try { if (photo != null && photo.ContentLength > 0) { string image = String.Concat(sta.sta_username, photo.FileName); var path = Path.Combine(Server.MapPath("~/Areas/Admins/Content/Photo/Staff/"), System.IO.Path.GetFileName(image)); photo.SaveAs(path); sta.sta_image = image; //Mail string content = System.IO.File.ReadAllText("D:/Kì 2 Năm 3/CNWEB/web_ieltsv2/coderush/Common/Template/sendmail.html"); content = content.Replace("{{Username}}", sta.sta_username); content = content.Replace("{{Password}}", sta.sta_password); new MailHelper().SendMail(sta.sta_email, "Thông tin tài khoản", content); } else { sta.sta_image = "tienmta7.png"; } sta.sta_created_at = DateTime.Now; dao.Create(sta); return(RedirectToAction("Index")); } catch (Exception ex) { Console.WriteLine(ex.Message); return(View("Error")); } } else { ViewBag.lst_gr = grDao.GetAll(); return(View(sta)); } }