Exemplo n.º 1
0
        //    [Authorize("Admin")]
        public async Task <IActionResult> GetDeliveryProfile(string id)
        {
            var user = await _userManager.Users.Include(x => x.DeliveryData).Where(e => e.Id == id).FirstOrDefaultAsync();

            UserEditDeliveryViewModel client = Mapper.Map <UserEditDeliveryViewModel>(user.DeliveryData);

            return(new OkObjectResult(client));
        }
Exemplo n.º 2
0
//    [EnableCors("CorsDevPolicy")]
        //    [Authorize("Admin")]
        public async Task <IActionResult> EditDeliveryProfile([FromBody] UserEditDeliveryViewModel userEditDeliveryViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var client = await _userManager.Users.Include(x => x.DeliveryData).Where(e => e.Id == userEditDeliveryViewModel.Id).FirstOrDefaultAsync();

            client.DeliveryData.DeliveryFirstName = userEditDeliveryViewModel.DeliveryFirstName;
            client.DeliveryData.DeliveryLastName  = userEditDeliveryViewModel.DeliveryLastName;
            client.DeliveryData.DeliveryAddress   = userEditDeliveryViewModel.DeliveryAddress;
            client.DeliveryData.DeliveryCity      = userEditDeliveryViewModel.DeliveryCity;
            client.DeliveryData.DeliveryPostCode  = userEditDeliveryViewModel.DeliveryPostCode;

            await _context.SaveChangesAsync();

            return(new OkObjectResult(client));
        }