private void SavedAsTemplate_fn(string templateName, Posting posting, string selectedRequirements, string selectedSkills, string selectedLocations, string selectedDays)
        {
            //var postingTemplateHS = new HashSet<int>(db.PostingTemplates.Where(pt => pt.PositionID == posting.PositionID).Select(pt => pt.PositionID));

            PostingTemplate postingTemplate = new PostingTemplate
            {
                templateName        = templateName,
                pstNumPosition      = posting.pstNumPosition,
                pstFTE              = posting.pstFTE,
                pstSalary           = posting.pstSalary,
                pstCompensationType = posting.pstCompensationType,
                pstJobDescription   = posting.pstJobDescription,
                pstOpenDate         = posting.pstOpenDate,
                pstEndDate          = posting.pstEndDate,
                pstJobStartDate     = posting.pstJobStartDate,
                pstJobEndDate       = posting.pstJobEndDate,
                PositionID          = posting.PositionID,
                RequirementIDs      = selectedRequirements,
                SkillIDs            = selectedSkills,
                LocationIDs         = selectedLocations,
                dayIDs              = selectedDays
            };

            //if (postingTemplateHS.Contains(posting.PositionID))
            //{
            //    var postingTemplateToDelete = db.PostingTemplates.Find(posting.PositionID);
            //    db.PostingTemplates.Remove(postingTemplateToDelete);
            //}

            db.PostingTemplates.Add(postingTemplate);
        }
        public ActionResult DeleteTemplate(string name)
        {
            if (name == "")
            {
                logger.Info("DeleteTemplate: Template name is blank (Bad Request)");
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PostingTemplate postingTemplate = db.PostingTemplates
                                              .Where(p => p.templateName == name).SingleOrDefault();

            try
            {
                db.PostingTemplates.Remove(postingTemplate);
                db.SaveChanges();
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try Again!");
            }
            return(RedirectToAction("Index"));
        }
 private void PopulateDropdownListTemplate(PostingTemplate postingTemplate = null)
 {
     ViewBag.PositionID = new SelectList(db.Positions.OrderBy(p => p.PositionDescription), "ID", "PositionDescription", postingTemplate?.PositionID);
 }