public JsonResult SaveNewProject(Projects model, string hdndokumanfile, string hdnimagefile) { using (DeneysanContext db = new DeneysanContext()) { model.PageSlug = Utility.SetPagePlug(model.ProjeAdi); model.TimeCreated = DateTime.Now; model.ProjectGroupId = 1; model.Status = 1; model.Language = "tr"; model.Online = true; if (!string.IsNullOrEmpty(hdnimagefile)) { model.ProjeDokümani = "/Content/projectfiles/" + hdndokumanfile; } db.Projects.Add(model); db.SaveChanges(); if (!string.IsNullOrEmpty(hdnimagefile)) { string[] imagesArray = hdnimagefile.Split(','); if (imagesArray != null && imagesArray.Length > 0) { for (int i = 0; i < imagesArray.Length; i++) { ProjectsGallery g = new ProjectsGallery(); g.ProjeId = model.ProjeId; g.Image = "/Content/images/projects/" + imagesArray[i]; g.ImageThumb = "/Content/images/projects/" + "thumb_" + imagesArray[i]; db.ProjectsGallery.Add(g); } } db.SaveChanges(); } } return Json(true); }
public JsonResult ProjeKaydet(Projects model, string hdndokumanfile, string hdnimagefile) { using (DeneysanContext db = new DeneysanContext()) { model.PageSlug = Utility.SetPagePlug(model.ProjeAdi); model.TimeCreated = DateTime.Now; model.Status = 0; model.Language = lang; model.Online = true; if (!string.IsNullOrEmpty(hdnimagefile)) { model.ProjeDokümani = "/Content/projectfiles/" + hdndokumanfile; } db.Projects.Add(model); db.SaveChanges(); if (!string.IsNullOrEmpty(hdnimagefile)) { string[] imagesArray = hdnimagefile.Split(','); if (imagesArray != null && imagesArray.Length > 0) { for (int i = 0; i < imagesArray.Length; i++) { ProjectsGallery g = new ProjectsGallery(); g.ProjeId = model.ProjeId; g.Image = "/Content/images/projects/" + imagesArray[i]; g.ImageThumb = "/Content/images/projects/" + "thumb_" + imagesArray[i]; db.ProjectsGallery.Add(g); } } db.SaveChanges(); var mset = MailManager.GetMailSettings(); var msend = MailManager.GetMailUsersList(1); using (var client = new SmtpClient(mset.ServerHost, mset.Port)) { client.EnableSsl = false; client.Credentials = new NetworkCredential(mset.ServerMail, mset.Password); var mail = new MailMessage(); mail.From = new MailAddress(mset.ServerMail); foreach (var item in msend) mail.To.Add(item.MailAddress); mail.Subject = "Yeni Proje Başvuru Bildirimi"; mail.IsBodyHtml = true; mail.Body = "<h5><b>" + model.ProjeSahibi + " isimli kişiden bir proje başvurusu sistemde kayıt altına alınmıştır</b></h5>"; if (mail.To.Count > 0) client.Send(mail); } } } return Json(true); }
public ActionResult EditProject(Projects model, string hdnProjeDokumani,string hdnimagefile) { using (DeneysanContext db = new DeneysanContext()) { model.PageSlug = Utility.SetPagePlug(model.ProjeAdi); if (!string.IsNullOrEmpty(hdnProjeDokumani)) { model.ProjeDokümani = "/Content/projectfiles/" + hdnProjeDokumani; } else model.ProjeDokümani = ""; model.TimeUpdated = DateTime.Now; db.SaveChanges(); if (!string.IsNullOrEmpty(hdnimagefile)) { string[] imagesArray = hdnimagefile.Split(','); if (imagesArray != null && imagesArray.Length > 0) { for (int i = 0; i < imagesArray.Length; i++) { ProjectsGallery g = new ProjectsGallery(); g.ProjeId = model.ProjeId; g.Image = "/Content/images/projects/" + imagesArray[i]; g.ImageThumb = "/Content/images/projects/" + "thumb_" + imagesArray[i]; db.ProjectsGallery.Add(g); } } db.SaveChanges(); } var languages = LanguageManager.GetLanguages(); var list = new SelectList(languages, "Culture", "Language", model.Language); ViewBag.LanguageList = list; return View(model); } }