示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        // 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));
            }
        }
示例#4
0
        public async Task <IActionResult> AddMember()
        {
            await _membersService.Add();

            return(Ok());
        }
示例#5
0
 public void AddMembership()
 {
     Input.LibraryMember.CardNumber = _membersService.RandomString();
     Input.LibraryMember.MemberType = MemberType.Manager;
     _membersService.Add(Input.LibraryMember);
 }
示例#6
0
 public void CreateLibraryMember()
 {
     Input.LibraryMember.CardNumber = _membersService.RandomString();
     Input.LibraryMember.MemberType = MemberType.Assistant;
     _membersService.Add(Input.LibraryMember);
 }