public ActionResult Create(MembersModel model) { if (ModelState.IsValid) { if (model.Password != model.Password2) { ModelState.AddModelError("Password", "两次输入的密码不一致!"); return(View(PluginHelper.GetViewPath(this.GetType(), "Create"), model)); } var info = new Members(); info = Mapper.Map <MembersModel, Members>(model); if (info != null) { service.Add(info); return(Json(new AjaxResult() { Result = Result.Success })); } } return(View(PluginHelper.GetViewPath(this.GetType(), "Create"), model)); }
public IActionResult Create([Bind("ID,FirstName,LastName,PersonNumber")] Member member) { bool PnumberCompare = _membersService.ComparePersonNumber(member); if (PnumberCompare == true) { TempData["fail"] = "fail"; return(View(member)); } if (ModelState.IsValid) { _membersService.Add(member); return(RedirectToAction(nameof(Index))); } return(View(member)); }
// POST api/members public async Task <HttpResponseMessage> Post(MemberBaseViewModel memberViewModel) { try { if (ModelState.IsValid) { var member = Mapper.Map <MemberBaseViewModel, Member>(memberViewModel); await _membersService.Add(member); return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid Model")); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <IActionResult> AddMember() { await _membersService.Add(); return(Ok()); }
public void AddMembership() { Input.LibraryMember.CardNumber = _membersService.RandomString(); Input.LibraryMember.MemberType = MemberType.Manager; _membersService.Add(Input.LibraryMember); }
public void CreateLibraryMember() { Input.LibraryMember.CardNumber = _membersService.RandomString(); Input.LibraryMember.MemberType = MemberType.Assistant; _membersService.Add(Input.LibraryMember); }