// public async Task EditAsync(EducationEditInputModel input, string userId)
        public async Task <int> EditAsync(ContactEditInputModel input, string userId)
        {
            var entity = await this.contactsRepository
                         .All()
                         .FirstOrDefaultAsync(x => x.Id == input.Id);

            // var userEntity = this.usersRepository.AllAsNoTracking()
            //    .FirstOrDefault(x => x.UserName == articleInputModel.UserId);
            // take the user and record its id in the article, product, conformity, etc.\\
            entity.Icon     = input.Icon.Trim();
            entity.Title    = input.Title.Trim();
            entity.Link     = input.Link.Trim();
            entity.LinkText = input.LinkText.Trim();
            entity.UserId   = userId;

            await this.contactsRepository.SaveChangesAsync();

            return(entity.Id);
        }
Esempio n. 2
0
        public async Task <ActionResult <ContactExportModel> > Put(int id, ContactEditInputModel input)
        {
            if (id != input.Id)
            {
                return(this.BadRequest());
            }

            var model = await this.contactsService.GetByIdAsync <ContactExportModel>(id);

            if (model == null)
            {
                return(this.NotFound());
            }

            // var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var user = await this.userManager.GetUserAsync(this.User);

            await this.contactsService.EditAsync(input, user.Id);

            return(this.NoContent());
        }