Пример #1
0
        public ActionResult Create(int[] LangId, Job job, string[] Title, string[] Description, HttpPostedFileBase Photo)
        {
            if (Photo != null)
            {
                string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + Photo.FileName.Replace(" ", "_");
                string path     = System.IO.Path.Combine(Server.MapPath("~/Uploads"), filename);
                Photo.SaveAs(path);
                job.Photo = filename;
            }
            job.PublishDate = DateTime.Now;
            job.Code        = 1;
            job.Status      = true;
            db.Jobs.Add(job);
            db.SaveChanges();
            for (int i = 0; i < LangId.Count(); i++)
            {
                JobLang newJobLang = new JobLang();
                newJobLang.LangId      = LangId[i];
                newJobLang.Status      = true;
                newJobLang.Title       = Title[i];
                newJobLang.Description = Description[i];
                newJobLang.JobId       = job.Id;
                db.JobLangs.Add(newJobLang);
            }
            db.SaveChanges();
            List <string> subsribers = db.Subscribers.Select(s => s.Email).ToList();

            foreach (string s in subsribers)
            {
                SendEmail(s, "*****@*****.**", "Yeni Vakansiya", "TEST");
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Edit(int JobId, int[] LangId, Job job, string[] Title, string[] Description, HttpPostedFileBase Photo, string OldPicture)
        {
            Job TheJob = db.Jobs.FirstOrDefault(f => f.Id == JobId);

            if (TheJob != null)
            {
                if (Photo != null)
                {
                    string filePath = Server.MapPath("~/Uploads/" + OldPicture);
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.Delete(filePath);
                    }

                    string filename = DateTime.Now.ToString("yyyyMMddHHmmss") + Photo.FileName.Replace(" ", "_");
                    string path     = System.IO.Path.Combine(Server.MapPath("~/Uploads"), filename);
                    Photo.SaveAs(path);
                    TheJob.Photo = filename;
                }
                TheJob.PublishDate  = DateTime.Now;
                TheJob.Code         = 1;
                TheJob.Location     = job.Location;
                TheJob.JobTypeId    = job.JobTypeId;
                TheJob.CategoryId   = job.CategoryId;
                TheJob.CompanyId    = job.CompanyId;
                TheJob.JobTypeId    = job.JobTypeId;
                TheJob.Salary       = job.Salary;
                TheJob.ExperienceId = job.ExperienceId;
                TheJob.Deadline     = job.Deadline;
                TheJob.Status       = true;
                db.SaveChanges();
            }


            for (int i = 0; i < LangId.Count(); i++)
            {
                int     TheLangId = LangId[i];
                JobLang OldJob    = db.JobLangs.FirstOrDefault(s => s.LangId == TheLangId);
                OldJob.Title       = Title[i];
                OldJob.Description = Description[i];
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }