public JsonResult CreateWork(string spaceKey, WorkExperienceEditModel model) { string message = string.Empty; if (ModelState.HasBannedWord(out message)) { return Json(new StatusMessageData(StatusMessageType.Error, message)); } long userId = UserIdToUserNameDictionary.GetUserId(spaceKey); WorkExperience work = model.AsWorkExperience(userId); bool result = userProfileService.CreateWorkExperience(work); if (result) return Json(new StatusMessageData(StatusMessageType.Success, "创建工作经历成功!")); else return Json(new StatusMessageData(StatusMessageType.Error, "创建工作经历失败!")); }
public ActionResult _EditUserWorkInfo(string spaceKey, long? workId) { User user = userService.GetFullUser(spaceKey); if (user == null) return HttpNotFound(); WorkExperienceEditModel editModel = new WorkExperienceEditModel(); int nowYear = DateTime.Now.Year; IList<string> startDateList = new List<string>(); for (int i = 0; i <= 50; i++) { startDateList.Add((nowYear - i).ToString()); } ViewData["StartDate"] = new SelectList(startDateList.Select(n => new { text = n.ToString(), value = n.ToString() }), "value", "text"); IDictionary<string, string> endDateDict = new Dictionary<string, string>(); endDateDict["至今"] = DateTime.Now.Year.ToString(); for (int i = 1; i <= 50; i++) { endDateDict[(nowYear - i).ToString()] = (nowYear - i).ToString(); } ViewData["EndDate"] = new SelectList(endDateDict.Select(n => new { text = n.Key, value = n.Value }), "value", "text"); if (workId.HasValue && workId > 0) { WorkExperience edu = userProfileService.GetWorkExperience(workId.Value, user.UserId); if (edu != null) editModel = edu.AsEditModel(); } return View(editModel); }