public ActionResult Create(MemberViewModel model) { ServiceResult result = new ServiceResult(); if (ModelState.IsValid) { try { MemberService.Create(model); result.Message = "添加Member成功!"; LogHelper.WriteLog("添加Member成功"); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加Member错误", ex); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); } return Json(result); }
public ActionResult Create() { var model = new MemberViewModel(); ViewBag.Data_GroupID = Utilities.GetSelectListData(GroupService.GetALL() , x => x.ID, x => x.Name, true); ViewBag.DepartJobTitle_LoadUrl = Url.Action("DepartJobTitleTree", "AjaxService"); ViewBag.DepartJobTitle_Prefix = "d_"; return PartialView(model); }
public Member Create(MemberViewModel model) { var entity = new Member(); entity.AddIP = HttpHelper.IP; entity.Address = model.Address; entity.AddTime = DateTime.Now; var djArray = model.DepartJobTitle.Split('_').Select(x => Convert.ToInt32(x)).ToList(); entity.DepartmentID = djArray[0]; entity.JobTitleID = djArray[1]; entity.Description = model.Description; entity.Email = model.Email; entity.GroupID = model.GroupID; entity.IsLeader = model.IsLeader; entity.IsLeap = model.IsLeap; entity.AvtarUrl = model.AvtarUrl; if (model.AddBirthDay) { entity.AddBirthDay = model.AddBirthDay; entity.IsLeap = model.IsLeap; if (entity.IsLeap) { entity.BirthDay1 = Utilities.GetLunarStringOnlyMonthDay(model.BirthDay); } entity.BirthDay = model.BirthDay; } else { entity.BirthDay = Utilities.TimeZero; } entity.BirthDay = model.BirthDay; entity.LastIP = HttpHelper.IP; entity.LastTime = DateTime.Now; entity.Mobile = model.Mobile; entity.Mobile1 = model.Mobile1; entity.NickName = model.NickName; entity.Password = CheckHelper.StrToMd5(model.Password); entity.QQ = model.QQ; entity.Sex = model.Sex; entity.StudyExp = model.StudyExp; entity.IDNumber = model.IDNumber; entity.JobExp = model.JobExp; //entity.JobTitleID = model.JobTitleID; entity.FamilySituation = model.FamilySituation; db.Add<Member>(entity); db.Commit(); if (entity.IsLeader) { var department = DepartmentService.Find(entity.DepartmentID); db.Attach<Department>(department); department.LeaderID = entity.MemberID; db.Commit(); } return entity; }