public async Task <IActionResult> PutFeatureRequestItem([FromRoute] string id, [FromBody] FeatureRequestItem featureRequestItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != featureRequestItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(featureRequestItem).State = EntityState.Modified;

            try
            {
                featureRequestItem.LastEditDate = DateTime.Now;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeatureRequestItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Register([FromBody] RegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userIdentity = _mapper.Map <AppUser>(model);

            var result = await _userManager.CreateAsync(userIdentity, model.Password);

            if (!result.Succeeded)
            {
                return(new BadRequestObjectResult(Error.AddErrorsToModelState(result, ModelState)));
            }

            await _appDbContext.AddAsync(new AppUser());

            await _appDbContext.SaveChangesAsync();

            return(new OkObjectResult("Account created"));
        }