Пример #1
0
        public async Task <InstitutionDTO> RegisterInstitution(Institution institution)
        {
            institution.Password = Cryptor.EncryptPassword(institution.Password);
            var result = await this.institutionRepository.CreateInstitution(institution);

            if (result != null)
            {
                return(this.mapper.Map <Institution, InstitutionDTO>(result));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public async Task <DataResult> ResetPassword(Institution institution)
        {
            var instFromServer = await this.institutionRepository.GetInstitutionById(institution.Id);

            if (Cryptor.DecryptPassword(instFromServer.Password, institution.Password))
            {
                instFromServer.Password = Cryptor.EncryptPassword(institution.NewPassword);
                var result = await this.institutionRepository.UpdatePassword(instFromServer);

                if (result > 0)
                {
                    var inst = this.mapper.Map <Institution, InstitutionDTO>(instFromServer);
                    return(new DataResult(inst, Message.Successful));
                }
                return(new DataResult(null, Message.ServerError));
            }
            return(new DataResult(null, Message.IncorrectPassword));
        }