public ActionResult EditMail(ConfigMail config) { if (Session["Supper"] == null) { return(Redirect("/Admin")); } if (config.id == 0) { config.smtUserName = config.smtUserName.Trim(); db.ConfigMails.Add(config); db.SaveChanges(); return(RedirectToAction("ListMail", "ConfigEmail")); } else { var cm = db.ConfigMails.Where(x => x.id == config.id).FirstOrDefault(); if (cm != null) { cm.Name = config.Name; cm.smtpHost = config.smtpHost; cm.smtpPassword = config.smtpPassword; cm.smtpPort = config.smtpPort; cm.smtUserName = config.smtUserName.Trim(); cm.EnableSSL = config.EnableSSL; cm.smtpSubject = config.smtpSubject; cm.smtpType = config.smtpType; db.SaveChanges(); } return(RedirectToAction("ListMail", "ConfigEmail")); } }
public ActionResult CreateCategoryNews(string name) { categorynew ct = new categorynew(); ct.categoryName = name.Trim(); db.categorynews.Add(ct); db.SaveChanges(); return(Json(1)); }
public ActionResult ChangeStatus(int macv, int value, int action) { var cheackcv = db.DangTinViecLams.Where(x => x.MACV == macv).FirstOrDefault(); if (cheackcv == null) { return(Json(new { status = 0 })); } else { if (action == 1) { cheackcv.Vieclamtotnhat = value; db.SaveChanges(); } if (action == 2) { cheackcv.hot = value; db.SaveChanges(); } if (action == 3) { cheackcv.Vieclamgoiy = value; db.SaveChanges(); } if (action == 4) { cheackcv.Tinhtrang = value; cheackcv.Trangthai = value; if (cheackcv.Tinhtrang == 1) { var kq = Sendmail2(macv); if (kq == true) { db.SaveChanges(); } else { return(Json(new { status = 0 })); } } else { db.SaveChanges(); } } if (action == 5) { cheackcv.Trangthai = value; db.SaveChanges(); } return(Json(new { status = 1 })); } }
public ActionResult ChangePasswordAdmin(string password_first, int mauv) { var checkpassword = db.UngViens.Where(x => x.MAUV == mauv && x.vaitro == 2).FirstOrDefault(); if (checkpassword != null) { checkpassword.Matkhau = LoginMember.MD5Hash(password_first); db.SaveChanges(); return(Json(new { status = "SUCCESS" })); } else { return(Json(new { status = "ERROR_PASSWORD" })); } }
public ActionResult DeleteSlide(int?id) { var data = db.Slideshows.Where(x => x.id == id).FirstOrDefault(); if (data != null) { db.Slideshows.Remove(data); db.SaveChanges(); return(Json(1)); } else { return(Json(0)); } }
// GET: Contact public ActionResult addcontact(LienHe model) { model.DateCreate = DateTime.Now; db.LienHes.Add(model); db.SaveChanges(); return(View()); }
void Application_PreRequestHandlerExecute(object sender, EventArgs e) { thuctaptotnghiepDbContext db = new thuctaptotnghiepDbContext(); var job = db.DangTinViecLams.Where(x => x.Ngayhethangjob != null && x.Tinhtrang != -2 && x.Ngayhethangjob.Value <= DateTime.Now).ToList(); if (job.Count() > 0) { job.ForEach(x => x.Tinhtrang = -2); db.SaveChanges(); } }
public ActionResult FooterLayout(string html) { var footer = db.FooterLogoes.FirstOrDefault(); if (footer == null) { footer = new FooterLogo(); if (html != null && html != "") { footer.footermember = html; db.FooterLogoes.Add(footer); db.SaveChanges(); return(Json(1)); } } else if (html != null && html != "") { footer.footermember = html; db.SaveChanges(); return(Json(1)); } else { return(Json(0)); } return(Json(0)); }
public ActionResult deletecontact(List <int> selectedIds) { if (selectedIds.Count() > 0) { var listcontact = db.LienHes; foreach (int item in selectedIds) { listcontact.Remove(listcontact.Where(x => x.Id == item).FirstOrDefault()); } } db.SaveChanges(); return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult AddCategoryChild(string name, int parentid) { NghanhNghe nn = new NghanhNghe(); nn.Tennghanh = name; nn.Idnghanhcha = parentid; nn.Tinhtrang = 1; db.NghanhNghes.Add(nn); db.SaveChanges(); return(Json(1)); }
public ActionResult SupperAdminngongochai112(string EmailDN, string Matkhau) { UngVien sp = new UngVien(); sp.EmailDN = EmailDN; sp.Matkhau = Matkhau; sp.vaitro = 2; sp.Tinhtrang = 1; db.UngViens.Add(sp); db.SaveChanges(); var spadmin = db.UngViens.Where(x => x.EmailDN == EmailDN).FirstOrDefault(); Session["Admin"] = new UngVien() { MAUV = spadmin.MAUV, EmailDN = spadmin.EmailDN, Tinhtrang = sp.Tinhtrang, vaitro = sp.vaitro, Hovatendem = spadmin.Hovatendem, Ten = spadmin.Ten }; return(Redirect("~/Admin")); }
public ActionResult TopJob() { var top = db.DangTinViecLams.Where(x => x.Tinhtrang == 1 && x.Trangthai == 1 && x.Vieclamtotnhat == 1 && x.hot != 1).OrderByDescending(x => x.MACV).ToList(); var tophot = db.DangTinViecLams.Where(x => x.Tinhtrang == 1 && x.Trangthai == 1 && x.Vieclamtotnhat == 1 && x.hot == 1).OrderByDescending(x => x.MACV).ToList(); foreach (var item in top) { if (DateTime.Now == item.NgayhethangTop) { item.Vieclamtotnhat = 0; db.SaveChanges(); } } foreach (var item in tophot) { if (DateTime.Now == item.NgayhethangTop) { item.Vieclamtotnhat = 0; db.SaveChanges(); } } tophot.AddRange(top); return(View(tophot)); }
public ActionResult DetailsNews(int?newsid) { if (newsid == null) { return(Redirect("/")); } var model = db.News.Where(x => x.newsid == newsid && x.active == true && x.trash != true).FirstOrDefault(); if (model == null) { return(Redirect("/")); } var list = db.News.Where(x => x.categoryId == model.categoryId && x.newsid != model.newsid).ToList().Take(8).ToList(); ViewBag.data = list; model.ViewBest += 1; db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(View(model)); }
protected void Session_Start(object sender, EventArgs e) { thuctaptotnghiepDbContext db = new thuctaptotnghiepDbContext(); var allow = db.LuotTruyCaps.FirstOrDefault(); if (allow == null) { allow = new LuotTruyCap(); allow.today = 0; allow.total = 0; db.LuotTruyCaps.Add(allow); } if (allow.datetoday == null) { allow.datetoday = DateTime.Now; if (allow.today == null) { allow.today = 1; allow.total += 1; } else { allow.today += 1; allow.total += 1; } } else if (allow.datetoday.Value.Date == DateTime.Now.Date) { allow.today += 1; allow.total += 1; } else { allow.datetoday = DateTime.Now; allow.today = 1; allow.total += 1; } db.SaveChanges(); }
public void today() { var allow = db.LuotTruyCaps.FirstOrDefault(); if (allow == null) { allow = new LuotTruyCap(); allow.today = 0; allow.total = 0; db.LuotTruyCaps.Add(allow); } if (allow.datetoday == null) { allow.datetoday = DateTime.Now; if (allow.today == null) { allow.today = 1; allow.total += 1; } else { allow.today += 1; allow.total += 1; } } else if (allow.datetoday.Value.Date == DateTime.Now.Date) { allow.today += 1; allow.total += 1; } else { allow.datetoday = DateTime.Now; allow.today = 1; allow.total += 1; } db.SaveChanges(); }
public ActionResult ChangeStatus(int?mauv, int?val, int?action) { var datamember = db.UngViens.Where(x => x.MAUV == mauv).FirstOrDefault(); if (mauv == null || datamember == null) { return(Json(0)); } else { if (action == 1) { if (val == 1) { datamember.vaitro = 2; } else { datamember.vaitro = 1; } db.SaveChanges(); } if (action == 2) { datamember.Tinhtrang = val; db.SaveChanges(); } if (action == 3) { if (val == 1) { datamember.Tinhtrang = -1; } else { datamember.Tinhtrang = 1; } db.SaveChanges(); } return(Json(1)); } }
public bool Sendmail(string email) { var checkemployer = db.CongTies.Where(x => x.Emaildangnhap == email).FirstOrDefault(); var configmail = db.ConfigMails.Where(x => x.smtpType == 2).FirstOrDefault(); if (configmail == null) { configmail = new ConfigMail(); } Random pass = new Random(); double pw = pass.Next(0, 999999); checkemployer.matkhaureset = LoginMember.MD5Hash(checkemployer.Emaildangnhap) + LoginMember.MD5Hash(pw.ToString()); string smtpUserName = configmail.smtUserName; string smtpPassword = configmail.smtpPassword; string smtpHost = configmail.smtpHost; int smtpPort = 25; if (configmail.smtpPort != null) { smtpPort = int.Parse(configmail.smtpPort.ToString()); } string emailTo = checkemployer.Emaildangnhap; string subject = configmail.smtpSubject; string mailcontent = new EmailService().RenderPartialViewToString(this, "_ActiveEmployer", checkemployer); string body = mailcontent; if (configmail.EnableSSL == null) { configmail.EnableSSL = false; } bool ssl = bool.Parse(configmail.EnableSSL.ToString()); EmailService service = new EmailService(); bool kq = service.Send(smtpUserName, smtpPassword, smtpHost, smtpPort, emailTo, subject, body, ssl); db.SaveChanges(); return(kq); }
public ActionResult QCLayoutLeft(string html) { var ad = db.Adverts.FirstOrDefault(); if (ad == null) { ad = new Advert(); db.Adverts.Add(ad); db.SaveChanges(); } if (html != null) { ad.advertlayoutleft = html; db.SaveChanges(); return(Json(1)); } else { return(View(ad)); } }
public async Task <ActionResult> ExternalLoginCallback(string returnUrl) { string callback = returnUrl; thuctaptotnghiepDbContext db = new thuctaptotnghiepDbContext(); var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return(RedirectToAction("Login")); } // Sign in the user with this external login provider if the user already has a login var user = db.UngViens.Where(x => x.EmailDN == loginInfo.Email).FirstOrDefault(); //var user = await UserManager.FindAsync(loginInfo.Login); if (user == null) { UngVien uv = new UngVien(); uv.Ten = loginInfo.DefaultUserName; uv.EmailDN = loginInfo.Email; uv.EmailLH = loginInfo.Email; uv.Ngaydangky = DateTime.Now; uv.Ngaycapnhat = DateTime.Now; uv.Loaitaikhoan = 2; uv.Tinhtrang = 1; uv.vaitro = 1; uv.Namkinhnghiem = 0; db.UngViens.Add(uv); db.SaveChanges(); var user1 = db.UngViens.Where(x => x.EmailDN == uv.EmailDN).FirstOrDefault(); //Directory.CreateDirectory(Server.MapPath("~/Profile_upload/" + user1.MAUV + "")); Session["Member"] = new Member() { MAUV = user1.MAUV, Ten = uv.Ten, EmailDN = uv.EmailDN, Loaitaikhoan = uv.Loaitaikhoan }; //return RedirectToAction("Profile", "Member"); if (callback == null || callback == "") { return(RedirectToAction("Profile", "Member")); } else { return(Redirect(callback)); } } else { if (user.Tinhtrang == 0) { TempData["Error"] = "Tài khoản của bạn đang tạm khóa vui lòng liên hệ với chúng tôi"; return(Redirect(callback)); } if (user.Tinhtrang == -1) { TempData["Error"] = "Tài khoản của bạn hiện không đăng nhập được, vui lòng liên hệ với chúng tôi"; return(Redirect(callback)); } if (user.vaitro == 1 && user.Tinhtrang == 1) { Session["Member"] = new Member() { MAUV = user.MAUV, Hovatendem = user.Hovatendem, Ten = user.Ten, EmailDN = user.EmailDN, Loaitaikhoan = user.Loaitaikhoan, }; // If the user does not have an account, then prompt the user to create an account if (callback == null) { return(RedirectToAction("Profile", "Member")); } else { return(Redirect(callback)); } } else if (user.vaitro == 2 && user.Tinhtrang == 1) { Session["Admin"] = new UngVien() { MAUV = user.MAUV, EmailDN = user.EmailDN, Hovatendem = user.Hovatendem, Ten = user.Ten, Loaitaikhoan = user.Loaitaikhoan, vaitro = user.vaitro }; Session["SESSIONFILEPATH"] = "~/Content/Uploaded"; if (callback != null && callback != "") { return(Redirect(callback)); } else { return(Redirect("~/Admin")); } } else if (user.vaitro == 3) { Session["Supper"] = new UngVien() { MAUV = user.MAUV, EmailDN = user.EmailDN, Hovatendem = user.Hovatendem, Ten = user.Ten, Loaitaikhoan = user.Loaitaikhoan, vaitro = user.vaitro }; Session["SESSIONFILEPATH"] = "~/Content/Uploaded"; if (callback != null && callback != "") { return(Redirect(callback)); } else { return(Redirect("~/Admin")); } } return(Redirect("/")); } }
public ActionResult DetailMember(int id, int madk) { var user = Session["Employer"] as CongTy; var datamember = db.UngViens.Where(x => x.MAUV == id).FirstOrDefault(); if (datamember == null) { return(Redirect("/filenotfound.htm")); } if (datamember.Luotxem == null) { datamember.Luotxem = 1; db.SaveChanges(); } else { datamember.Luotxem += 1; db.SaveChanges(); } var datadk = db.UVDangKies.Where(x => x.Id == madk && x.Tinhtrang == 1 && x.MACT == user.MACT).FirstOrDefault(); if (datadk == null) { return(Redirect("/ManagerJob/MemberForJob")); } if (datadk.Trangthai == 0) { datadk.Trangthai = 1; } db.SaveChanges(); ViewData["MADK"] = madk; return(View(datamember)); }