public static ServerUser_PostView EntityMap(this ServerUser_Post model) { return(Mapper.Map <ServerUser_Post, ServerUser_PostView>(model)); }
public ActionResult AddJobOpt(FormCollection forms) { var userInfo = UserManage.GetCurrentUserInfo(); if (userInfo == null) { //未登录 return(GetJson(-1, new { flag = 1 })); } if (userInfo.IdentityType == IdentityType.ServerUser) { string jobName = forms["jobName"] ?? ""; string jobclassify = forms["jobclassify"] ?? ""; string workAddress = forms["workAddress"] ?? ""; string salary = forms["salary"] ?? ""; string sellingPoints = forms["sellingPoints"] ?? ""; string postDuty = forms["postDuty"] ?? ""; if (string.IsNullOrWhiteSpace(jobName)) { //职位名称必填 return(GetJson(0, new { falg = 1 })); } if (string.IsNullOrWhiteSpace(jobclassify)) { //职位类别必填 return(GetJson(0, new { falg = 2 })); } if (string.IsNullOrWhiteSpace(workAddress)) { //工作地点必填 return(GetJson(0, new { falg = 3 })); } var salaryList = new List <string>() { "3k以下", "3k-5k", "5k-10k", "10k以上" }; if (string.IsNullOrWhiteSpace(salary) || salaryList.Any(item => item == salary)) { salary = salaryList.First(); } if (string.IsNullOrWhiteSpace(sellingPoints)) { sellingPoints = ""; } if (string.IsNullOrWhiteSpace(postDuty)) { //职位描述必填 return(GetJson(0, new { falg = 4 })); } var serverUser = _ServerUserServices.QueryWhere(where => where.SerUserID == userInfo.UserId).FirstOrDefault(); if (serverUser == null) { //经纪人不存在 return(GetJson(2, new { falg = 1 })); } var serverUserPost = new ServerUser_Post() { SerUserID = serverUser.SerUserID, Company = serverUser.Company, Trade = jobclassify, PostName = jobName, PostDuty = postDuty, Salary = salary, WorkAdress = workAddress, CompanyMatching = sellingPoints, CreateTime = DateTime.Now, SeeCount = 0 }; _ServerUser_PostServices.Add(serverUserPost); if (_ServerUser_PostServices.SaveChanges() > 0) { return(GetJson(1)); } else { return(GetJson(3)); } } else { //身份错误 return(GetJson(-1, new { flag = 2 })); } }