Exemplo n.º 1
0
        public virtual async Task <IActionResult> CreateUser([FromBody] User user)
        {
            LogEnter("CreateUser", user);
            IActionResult result;

            if (TryValidateModel(user))
            {
                MemberEntity member = _mapper.Map <MemberEntity>(user);
                if (member != null)
                {
                    var newMember = await _repo.CreateMemberAsync(member);

                    result = CreatedAtAction(nameof(ShowUserById), new { id = newMember.Id });
                }
                else
                {
                    result = BadRequest();
                }
            }
            else
            {
                result = BadRequest();
            }
            LogExit("CreateUser", result);
            return(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([FromForm] Member member)
        {
            if (ModelState.IsValid)
            {
                await _repository.CreateMemberAsync(member);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }
        public async Task <ActionResult> Create(Member member)
        {
            if (ModelState.IsValid)
            {
                await _repo.CreateMemberAsync(member);

                return(RedirectToAction("Index"));
            }

            return(View(member));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> AddMember([FromForm] Member member)
        {
            if (ModelState.IsValid)
            {
                await _memberRepository.CreateMemberAsync(member);

                await _welcomeMail.SendWelcomeEmail(member.Email, member.FirstName);

                return(View("MemberAdded"));
            }
            return(View(member));
        }
Exemplo n.º 5
0
        public async Task <ActionResult <int> > CreateMember(MemberProfile member)
        {
            var result = await _repository.CreateMemberAsync(member);

            return(Ok(result));
        }