Example #1
0
        public IHttpActionResult AddorEditAddress(AddressPostDto addressPostDto)
        {
            if (!ModelState.IsValid)
            {
                var a  = ModelState.Values.SelectMany(msE => msE.Errors).Select(err => err.ErrorMessage);
                var bf = "";
                foreach (var item in a)
                {
                    bf += item + ",";
                }
                return(BadRequest(bf));
            }

            addressPostDto.MatchWithUser(userID);
            var address = Mapper.Map <AddressPostDto, Address>(addressPostDto);

            _addressRepository.AddOrEdit(address);

            _unitOfWork.Save();

            return(Ok());
        }