コード例 #1
0
        public JsonResult Edit(JobOpening model, List <string> reqSkill, string minExp, string maxExp)
        {
            var currUser = CurrentUser;

            if (reqSkill == null || !reqSkill.Any())
            {
                ModelState.AddModelError("", "Add atleast one desired skill");
            }
            if (!model.UpdateExperience(minExp, maxExp))
            {
                ModelState.AddModelError("", "Maximum experience should not be less than minimum experience");
            }
            if (model.JobPostId != 0 && model.UserId != currUser.UserId)
            {
                LogUnAuth();
                ModelState.AddModelError("", Strings.UnAuthAccess);
            }
            if (ModelState.IsValid)
            {
                model.UserName = currUser.FullName;
                model.UserId   = currUser.UserId;
                model.UpdateSkills(reqSkill);
                if (model.JobPostId == 0)
                {
                    _db.JobOpenings.Add(model);
                }
                else
                {
                    _db.Entry(model).State = System.Data.EntityState.Modified;
                }
                model.UpdatedOn = DateTime.UtcNow;
                _db.SaveChanges();
            }
            return(GetErrorMsgJSON());
        }