Ejemplo n.º 1
0
        public object GetListAvatar()
        {
            AvatarRepository repository = new AvatarRepository();


            return(repository.GetItens());
        }
Ejemplo n.º 2
0
        public void AddAvatar(Avatar item)
        {
            AvatarRepository repository = new AvatarRepository();


            //Gerar novo ID
            item.Id = Guid.NewGuid();
            repository.Add(item);
        }
Ejemplo n.º 3
0
        public Avatar GetAvatar(Guid id)
        {
            AvatarRepository repository = new AvatarRepository();

            var usu = repository.GetItem(id);

            if (usu == null)
            {
                throw new Exception("User does not exists");
            }
            return(usu);
        }
Ejemplo n.º 4
0
 public AvatarController(ApplicationDbContext context, IConfiguration configuration)
 {
     _avatarRepository = new AvatarRepository(context);
 }
Ejemplo n.º 5
0
        PostProfileAsync(IUserViewModel uploadModel, RequestContext requestContext)
        {
            var profileResult        = new IdentityManagerResult <PostProfileResultState, (IUserViewModel, string)>();
            var userTitle            = Dependencies.LocalizationService.Localize("General.User");
            var userDoesntExistTitle = Dependencies.LocalizationService.Localize("Adm.User.NotExist");

            profileResult.Data = (uploadModel, userTitle);
            MedioClinicUser user = null;

            try
            {
                user = await UserManager.FindByIdAsync(uploadModel.CommonUserViewModel.Id);
            }
            catch (Exception ex)
            {
                HandlePostProfileException(ref profileResult, ex, PostProfileResultState.UserNotFound);
                profileResult.Data = (uploadModel, userDoesntExistTitle);

                return(profileResult);
            }

            var commonUserModelCustomMappings = new Dictionary <(string propertyName, Type propertyType), object>
            {
                { (nameof(MedioClinicUser.Email), typeof(string)), uploadModel.CommonUserViewModel.EmailViewModel.Email },
            };

            try
            {
                // Map the common user properties.
                user = UserModelService.MapToMedioClinicUser(uploadModel.CommonUserViewModel, user, commonUserModelCustomMappings);

                // Map all other potential properties of specific models (patient, doctor, etc.)
                user = UserModelService.MapToMedioClinicUser(uploadModel, user);
            }
            catch (Exception ex)
            {
                HandlePostProfileException(ref profileResult, ex, PostProfileResultState.UserNotMapped);

                return(profileResult);
            }

            try
            {
                // We need to use the user store directly due to the design of Microsoft.AspNet.Identity.Core.UserManager.UpdateAsync().
                await UserStore.UpdateAsync(user);

                var avatarFile = uploadModel.CommonUserViewModel.AvatarFile;

                if (avatarFile != null)
                {
                    var avatarBinary = FileManager.GetPostedFileBinary(avatarFile);
                    AvatarRepository.UploadUserAvatar(user, avatarBinary);
                }
            }
            catch (Exception ex)
            {
                HandlePostProfileException(ref profileResult, ex, PostProfileResultState.UserNotUpdated);

                return(profileResult);
            }

            (var model, var title) = GetViewModelByUserRoles(user, requestContext, true);

            if (model != null)
            {
                profileResult.Success     = true;
                profileResult.ResultState = PostProfileResultState.UserUpdated;
                profileResult.Data        = (model, title);
            }

            return(profileResult);
        }