public async Task <IActionResult> PutNumberSequence([FromBody] NumberSequence numberSequence)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            await _context.SaveChangesAsync();

            return(Ok());
        }
Пример #2
0
        public async Task <IActionResult> PostUploadProfilePicture(List <IFormFile> UploadDefault)
        {
            try
            {
                var folderUpload = "upload";
                var fileName     = await _functionalService.UploadFile(UploadDefault, _env, folderUpload);

                ApplicationUser appUser = await _userManager.GetUserAsync(User);

                if (appUser != null)
                {
                    UserProfile profile = _context.UserProfile.SingleOrDefault(x => x.ApplicationUserId.Equals(appUser.Id));
                    if (profile != null)
                    {
                        profile.ProfilePicture = "/" + folderUpload + "/" + fileName;
                        _context.UserProfile.Update(profile);
                        await _context.SaveChangesAsync();
                    }
                }
                return(Ok(fileName));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { message = ex.Message }));
            }
        }
Пример #3
0
        public async Task <IActionResult> Insert([FromBody] CrudViewModel <UserProfile> payload)
        {
            UserProfile register = payload.value;

            if (register.Password.Equals(register.ConfirmPassword))
            {
                ApplicationUser user = new ApplicationUser()
                {
                    Email = register.Email, UserName = register.Email, EmailConfirmed = true
                };
                var result = await _userManager.CreateAsync(user, register.Password);

                if (result.Succeeded)
                {
                    register.Password          = user.PasswordHash;
                    register.ConfirmPassword   = user.PasswordHash;
                    register.ApplicationUserId = user.Id;
                    _context.UserProfile.Add(register);
                    await _context.SaveChangesAsync();
                }
            }
            return(Ok(register));
        }