예제 #1
0
        public ActionResult SaveJob(Job job)
        {
            string message = "";

            if (ModelState.IsValid)
            {
                //job.JobTitle = ToCamelCase(job.JobTitle);
                if (Convert.ToInt32(job.JobTrendingTagsMappingList.Count) == 0)
                {
                    if (Session["TrendingTagsList"] != null)
                    {
                        job.JobTrendingTagsMappingList = (List <JobTrendingTagsMapping>)Session["TrendingTagsList"];
                    }
                }

                if (Convert.ToInt32(job.JobSkillsMappingList.Count) == 0)
                {
                    if (Session["SkillsList"] != null)
                    {
                        job.JobSkillsMappingList = (List <JobSkillsMapping>)Session["SkillsList"];
                    }
                }


                job.UserId = Convert.ToInt32(Session["UserId"]);


                List <JobDocuments> fileList = new List <JobDocuments>();

                if (TempData["fileList"] != null)
                {
                    fileList = (List <JobDocuments>)TempData.Peek("fileList");
                }

                if (job != null)
                {
                    if (Convert.ToInt32(job.JobDocumentsList.Count) == 0)
                    {
                        if (fileList != null)
                        {
                            foreach (var file in fileList)
                            {
                                job.JobDocumentsList.Add(new JobDocuments()
                                {
                                    DocumentName = file.DocumentName.ToString(), IsActive = "Y", Filesize = file.Filesize
                                });
                            }
                        }
                    }
                }

                var _tagsObjModel = new TrendingTagsModel();
                foreach (var item in job.JobTrendingTagsMappingList)
                {
                    if (item.TrendingTagsId == 0)
                    {
                        var _trendingTag = new TrendingTags()
                        {
                            Description    = item.Description,
                            TrendingTagsId = item.TrendingTagsId,
                            JobCategoryId  = job.JobCategoryId,
                            TagType        = "U"
                        };
                        item.TrendingTagsId = objTrendingMod.Save(_trendingTag);
                    }
                }
                var jobId = 0;
                if ((jobId = objJobMod.SaveWithTransaction(job)) > 0)
                {
                    if (Session["UserType"] != null && Session["UserType"].ToString() == "1")
                    {
                        Session["UserType"] = "3";
                        UsersModel _Model   = new UsersModel();
                        Users      _userobj = new Users();
                        _userobj.UserId   = Convert.ToInt32(Session["UserId"]);
                        _userobj.UserType = Session["UserType"].ToString();
                        int k = _Model.ChangeUserRole(_userobj);
                    }
                    if (job.JobId > 0)
                    {
                        message = "Your job has been edited and is now pending for approval";
                        MatchBxCommon.sendJobPostedEmailToAdmin(2, job.JobTitle, job.JobId);
                        TempData["postJob"]   = job.JobId;
                        TempData["DeleteJob"] = 0;
                    }
                    else
                    {
                        // message = "Your job has been posted and is now live";
                        message = "Your job has been posted and is now pending for approval";
                        MatchBxCommon.sendJobPostedEmailToAdmin(1, job.JobTitle, jobId);
                        TempData["postJob"]   = 0;
                        TempData["DeleteJob"] = 0;
                    }

                    TempData.Remove("fileList");
                    Session["FileList"]  = null;
                    Session["JobPosted"] = "Y";
                }
                else
                {
                    if (job.JobId > 0)
                    {
                        message = "Failed to edit job";
                    }
                    else
                    {
                        message = "Failed to post job";
                    }

                    TempData.Remove("fileList");
                    Session["FileList"] = null;

                    Session["JobPosted"] = "N";
                }
                if (Convert.ToInt32(Session["UserType"]) != 3)
                {
                    Session["FirstLogin"] = "******";
                }
            }
            else
            {
                message = "Failed to post job";

                TempData.Remove("fileList");
                Session["FileList"]   = null;
                Session["JobPosted"]  = "N";
                Session["FirstLogin"] = "******";
            }

            return(Json(message, JsonRequestBehavior.AllowGet));
        }