Exemplo n.º 1
0
        public static bool AddProject(Projects record)
        {
            using (DeneysanContext db = new DeneysanContext())
            {
                try
                {
                    record.TimeCreated = DateTime.Now;
                    record.SortOrder = 9999;
                    record.Online = true;
                    db.Projects.Add(record);
                    db.SaveChanges();

                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }

        }
Exemplo n.º 2
0
 public ActionResult AddProject(Projects newmodel, HttpPostedFileBase uploadfile)
 {
     var languages = LanguageManager.GetLanguages();
     var list = new SelectList(languages, "Culture", "Language");
     ViewBag.LanguageList = list;
     if (ModelState.IsValid)
     {
         if (uploadfile != null && uploadfile.ContentLength > 0)
         {
             Random random = new Random();
             int rand = random.Next(1000, 99999999);
             uploadfile.SaveAs(Server.MapPath("/Content/images/projects/" + Utility.SetPagePlug(newmodel.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName)));
             newmodel.ProjectFile = "/Content/images/projects/" + Utility.SetPagePlug(newmodel.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName);
         }
         newmodel.PageSlug = Utility.SetPagePlug(newmodel.Name);
         newmodel.TimeCreated = DateTime.Now;
         ViewBag.ProcessMessage = ProjectManager.AddProject(newmodel);
         ModelState.Clear();
         
         return View();
     }
     else
         return View();
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public static bool EditProject(Projects Projectmodel)
        {
            using (DeneysanContext db = new DeneysanContext())
            {
                try
                {
                    Projects record = db.Projects.Where(d => d.ProjectId == Projectmodel.ProjectId).SingleOrDefault();
                    if (record != null)
                    {
                        record.Content = Projectmodel.Content;
                        record.Name = Projectmodel.Name;
                        
                        record.Language = Projectmodel.Language;
                        if (!string.IsNullOrEmpty(Projectmodel.ProjectFile))
                        {
                            record.ProjectFile = Projectmodel.ProjectFile;
                        }
                        record.Content = Projectmodel.Content;
                        db.SaveChanges();

                       

                        return true;
                    }
                    else
                        return false;

                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);

              }
        }
Exemplo n.º 7
0
        public ActionResult EditProject(Projects newmodel, HttpPostedFileBase uploadfile)
        {
            var languages = LanguageManager.GetLanguages();
            var list = new SelectList(languages, "Culture", "Language");
            ViewBag.LanguageList = list;

            if (ModelState.IsValid)
            {
                if (uploadfile != null && uploadfile.ContentLength > 0)
                {
                    Random random = new Random();
                    int rand = random.Next(1000, 99999999);
                    uploadfile.SaveAs(Server.MapPath("/Content/images/projects/" + Utility.SetPagePlug(newmodel.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName)));
                    newmodel.ProjectFile = "/Content/images/projects/" + Utility.SetPagePlug(newmodel.Name) + "_" + rand + Path.GetExtension(uploadfile.FileName);
                }

                newmodel.PageSlug = Utility.SetPagePlug(newmodel.Name);

                if (RouteData.Values["id"] != null)
                {
                    int nid = 0;
                    bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                    if (isnumber)
                    {
                        newmodel.ProjectId = nid;
                        ViewBag.ProcessMessage = ProjectManager.EditProject(newmodel);
                        return View(newmodel);
                    }
                    else
                    {
                        ViewBag.ProcessMessage = false;
                        return View(newmodel);
                    }
                }
                else return View();
            }
            else
                return View();

            return View();
        }