public ActionResult <MemberDTO_Return> CreateMember(MemberDTO_Create memberDTO)
        {
            var dummyMember = _memberMapper.DTOToDummyMemberObject(memberDTO);

            var member = _memberService.CreateNewMember(dummyMember);

            if (member == null)
            {
                return(BadRequest("Not valid"));
            }

            var result = _memberService.AddPhonenumersAndLicensPlatesToMember(dummyMember, member);

            if (!result)
            {
                return(BadRequest("Not valid"));
            }

            return(Ok(_memberMapper.MemberToDTOReturn(member)));
        }
Example #2
0
        public ActionResult <MemberDTO_Return> CreateMember(MemberDTO_Create memberDTO)
        {
            var dummyMember = _memberMapper.DTOToDummyMemberObject(memberDTO);

            var member = _memberService.CreateNewMember(dummyMember);

            if (member == null)
            {
                //Good, but state what is wrong: BadRequest("Member could not be created")
                return(BadRequest("Not valid"));
            }

            var result = _memberService.AddPhonenumersAndLicensPlatesToMember(dummyMember, member);

            if (!result)
            {
                //Good, but state what is wrong: BadRequest("Member's subdata could not be created")
                //Better yet, do everything in one method and SaveChanges to create an atomic save (all or nothing)
                return(BadRequest("Not valid"));
            }

            return(Ok(_memberMapper.MemberToDTOReturn(member)));
        }