コード例 #1
0
ファイル: AuthManager.cs プロジェクト: ItayTur/Social-Network
        /// <summary>
        /// Adds a user entity to the users database through the identity service.
        /// </summary>
        /// <param name="appToken"></param>
        /// <param name="user"></param>
        private async Task AddUserToUsersDb(string appToken, RegistrationDto registrationDto, string userId)
        {
            try
            {
                using (HttpClient httpClient = new HttpClient())
                {
                    var user = new UserModel()
                    {
                        Id               = userId,
                        FirstName        = registrationDto.FirstName,
                        LastName         = registrationDto.LastName,
                        Email            = registrationDto.Email,
                        Address          = registrationDto.Address,
                        Job              = registrationDto.Job,
                        BirthDate        = registrationDto.BirthDate,
                        RegistrationType = RegistrationTypeEnum.UserNamePassword.ToString(),
                        RegistrationKey  = registrationDto.Email
                    };
                    var data = new JObject();
                    data.Add("user", JToken.FromObject(user));
                    data.Add("token", JToken.FromObject(appToken));
                    var response = await httpClient.PostAsJsonAsync(_identityUrl, data);

                    if (!response.IsSuccessStatusCode)
                    {
                        throw new Exception("Identity server could not add the user");
                    }
                }
            }
            catch (Exception e)
            {
                //TODO: log
                throw new AddUserToDbException(e.Message);
            }
        }
コード例 #2
0
        public Registrations_tests()
        {
            _registrationController = new RegistrationController(_IRegistrationRepoMock.Object);

            _registrationDto = new RegistrationDto()
            {
                Title         = "Test",
                Description   = "This is a test",
                DateTime      = DateTime.Now,
                DoctorComment = "test comment",
                EmployeeId    = 1,
                PatientId     = 3
            };

            _registrationCreate = new RegistrationCreate()
            {
                Title       = "Test",
                Description = "This is a test",
                DateTime    = DateTime.Now,
                EmployeeId  = 1,
                PatientId   = 3
            };

            _registrationUpdate = new RegistrationUpdate()
            {
                Title         = "Updated Test",
                Description   = "This is a test",
                DateTime      = DateTime.Now,
                DoctorComment = "test comment",
                EmployeeId    = 1,
                PatientId     = 3,
            };
        }
コード例 #3
0
ファイル: ShipmentService.cs プロジェクト: merken/efc-txn
        private async Task AddPackage(RegistrationDto registration, int memberId, Shipment.ShipmentType type, DateTime date)
        {
            var member = await context.Members.FindAsync(memberId);

            if (member == null)
            {
                throw new ArgumentException($"Member with id {memberId} does not exist");
            }

            await context.Shipments.AddAsync(new Shipment
            {
                Address = new Address
                {
                    Street       = registration.Street,
                    StreetNumber = registration.StreetNumber,
                    City         = registration.City,
                    State        = registration.State,
                    Country      = registration.Country,
                },
                MemberId = member.Id,
                Type     = type,
                Date     = date
            });

            await context.SaveChangesAsync();
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="registrationDTO">Registration data transfer object</param>
        /// <returns>Created user id.</returns>

        public async Task <string> RegisterAsync(RegistrationDto registrationDTO)
        {
            // map dto to AppUser class
            var user = _mapper.Map <AppUser>(registrationDTO);

            // Try to create the new user
            var result = await _userManager.CreateAsync(user, registrationDTO.Password);

            // If it fails throw an exception
            if (!result.Succeeded)
            {
                throw new InvalidOperationException(result.ErrorMessage());
            }
            var customer = new Customer {
                IdentityId = user.Id
            };

            // Add new user to customers table with the identity id assigned.
            await _context.Customers.AddAsync(customer);

            // Commit changes to database
            await _context.SaveChangesAsync();

            return(customer.IdentityId);
        }
コード例 #5
0
        public async Task<User> Register(RegistrationDto registrationDto)
        {
            // byteArrays of passwordHash and passwordSalt
            byte[] passwordHash, passwordSalt;

            // The out keyword creates a reference of the variables.
            // When they are updated, within the CreateHashPassword, it will be updated locally within the method
            CreateHashPassword(registrationDto.Password, out passwordHash, out passwordSalt);

            var newUser = new User();

            newUser.PasswordHash = passwordHash;
            newUser.PasswordSalt = passwordSalt;

            newUser = new User
            {
                Username = registrationDto.Username,
                Email = registrationDto.Email,
                PasswordHash = newUser.PasswordHash,
                PasswordSalt = newUser.PasswordSalt
            };

            _userRepository.Add(newUser);
            return newUser;
        }
コード例 #6
0
        public async Task <IActionResult> Register(RegistrationDto model)
        {
            if (ModelState.IsValid)
            {
                User user = new User()
                {
                    Name       = model.Name,
                    Email      = model.Email,
                    UserName   = model.Email,
                    Surename   = model.Surename,
                    Patronymic = model.Patronymic,
                };

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

                if (result.Succeeded)
                {
                    if (string.IsNullOrEmpty(model.ReturnUrl))
                    {
                        return(RedirectToAction("GetTasks", "TaskBoard"));
                    }
                    return(RedirectToAction(model.ReturnUrl.Split("/")[1], model.ReturnUrl.Split("/")[0]));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }

            return(View("Register"));
        }
コード例 #7
0
        public async Task Register_CallWithMockedIAuthentication_ThrowsAndCatchesDbUpdateException()
        {
            // Arrange
            var mock            = new Mock <IAuthentication>();
            var registrationDto = new RegistrationDto()
            {
                Username             = "******",
                Email                = "*****@*****.**",
                Password             = "******",
                PasswordConfirmation = "password",
                Locale               = "en-US",
                Timezone             = "Asia/Calcutta",
            };

            string exceptionMessage = ExceptionMessage.UniquenessConstraintViolation;
            var    ex = new DbUpdateException(exceptionMessage);

            mock.Setup(auth => auth.RegisterUserAsync(registrationDto)).ThrowsAsync(ex);
            var authController = new AuthController(mock.Object);

            // Act
            var result = await authController.Register(registrationDto);

            var response     = (BadRequestObjectResult)result;
            var objectResult = (ResponseDto <ErrorDto>)response.Value;

            // Assert
            Assert.Equal(exceptionMessage, objectResult.Data.Message);
        }
コード例 #8
0
ファイル: Registration.cs プロジェクト: aidbal/Mindfights
        public async Task <RegistrationDto> GetMindfightTeamRegistration(long mindfightId, long teamId)
        {
            var currentMindfight = await _mindfightRepository
                                   .GetAll()
                                   .FirstOrDefaultAsync(x => x.Id == mindfightId);

            if (currentMindfight == null)
            {
                throw new UserFriendlyException("Protmūšis su nurodytu id neegzistuoja!");
            }

            var currentTeam = await _teamRepository
                              .GetAll()
                              .FirstOrDefaultAsync(x => x.Id == teamId);

            if (currentTeam == null)
            {
                throw new UserFriendlyException("Komanda su nurodytu id neegzistuoja!");
            }

            var currentRegistration = await _registrationRepository
                                      .GetAllIncluding(x => x.Mindfight, x => x.Team)
                                      .FirstOrDefaultAsync(x => mindfightId == x.MindfightId && teamId == x.TeamId);

            var registrationDto = new RegistrationDto();

            if (currentRegistration != null)
            {
                _objectMapper.Map(currentRegistration, registrationDto);
                registrationDto.MindfightName = currentMindfight.Title;
            }
            return(registrationDto);
        }
コード例 #9
0
        public async Task Register_CallWithMockedIAuthentication_ReturnsOkObjectResult()
        {
            // Arrange
            var mock            = new Mock <IAuthentication>();
            var registrationDto = new RegistrationDto()
            {
                Username             = "******",
                Email                = "*****@*****.**",
                Password             = "******",
                PasswordConfirmation = "password",
                Locale               = "en-US",
                Timezone             = "Asia/Calcutta",
            };

            var jsonWebToken = new JsonWebTokenDto("expected_token");

            mock.Setup(auth => auth.RegisterUserAsync(registrationDto)).ReturnsAsync(jsonWebToken);
            var authController = new AuthController(mock.Object);

            // Act
            var result = await authController.Register(registrationDto);

            var response     = (OkObjectResult)result;
            var objectResult = (ResponseDto <JsonWebTokenDto>)response.Value;

            // Assert
            Assert.Equal(jsonWebToken.Token, objectResult.Data.Token);
        }
コード例 #10
0
        public RegistrationResultDto Update([FromBody] RegistrationDto registrationDto)
        {
            if (!registrationDto.RegistrationId.HasValue)
            {
                throw new InvalidOperationException("No registration id provided. Can not update registration.");
            }

            var model = _registrationRepository.GetById(registrationDto.RegistrationId.Value);

            if (model.Status == RegistrationStatus.Committed)
            {
                throw new InvalidOperationException("The registration is already committed.");
            }

            _mapper.Map(source: registrationDto, destination: model);
            _mapper.Map(source: registrationDto, destination: model.Applicant);
            _collectionMapper.MapCollection(source: registrationDto.Participants, destination: model.RegistrationParticipants);

            _unitOfWork.Commit();

            _queue.Publish(new InterestRegisteredChangedMessage(model.Id));

            return(new RegistrationResultDto
            {
                ApplicantId = model.ApplicantId,
                RegistrationId = model.Id
            });
        }
コード例 #11
0
        public async Task <IActionResult> Login(
            [FromServices] IConfiguration configuration,
            [FromServices] IMediator mediator,
            [FromServices] IMapper mapper,
            [FromBody] RegistrationDto registrationDto)

        {
            var query = new GetProfileByLoginQuery(registrationDto.ProfileDto.Login);
            var data  = await mediator.Send(query);

            var actual = SaltHelper.Hash(registrationDto.Password, data.Profile.Secret.Salt);

            if (actual != data.Profile.Secret.Hash)
            {
                return(ValidationProblem("Invalid login or password"));
            }

            var claims = AuthHelper.GetIdentity(data.Profile.Login, data.Profile.Id);
            var token  = AuthHelper.GenerateToken(claims, configuration);

            var profile     = mapper.Map <ProfileDto>(data.Profile);
            var loginedUser = new LoginedProfileDto
            {
                Token      = token,
                ProfileDto = profile
            };

            return(new JsonResult(loginedUser));
        }
コード例 #12
0
        public async Task <IActionResult> Register([FromBody] RegistrationDto registerDto)
        {
            if (ModelState.IsValid)
            {
                var resultRegister = await _authorizationService.RegisterUserAsync(registerDto);

                if (!resultRegister.Succeeded)
                {
                    return(BadRequest());
                }
                var resultSignIn = await _authorizationService.LoginUserAsync(new LoginDto { Email = registerDto.Email, Password = registerDto.Password });

                if (!resultSignIn.Succeeded)
                {
                    return(BadRequest());
                }
                var token = _authorizationService.GenerateJwt(registerDto.Email);
                if (token != null)
                {
                    return(Ok(new { token }));
                }
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(BadRequest());
        }
コード例 #13
0
        public async Task <Status> Register(RegistrationDto registrationDto)
        {
            var user = _mainDbContext.Users.Any(u => u.Username == registrationDto.Username);

            if (user)
            {
                var status = new Status
                {
                    Success = false,
                    Message = $"User with login {registrationDto.Username} exist"
                };
                return(status);
            }

            var salt         = Guid.NewGuid().ToString();
            var passwordHash = PrepareHashPassword(registrationDto.Password, salt, registrationDto.IsPasswordKeptAsHash);

            var newUser = new User
            {
                Username            = registrationDto.Username,
                PasswordHash        = passwordHash,
                Salt                = salt,
                IsPasswordKeptAsSha = registrationDto.IsPasswordKeptAsHash
            };

            await _mainDbContext.AddAsync(newUser);

            await _mainDbContext.SaveChangesAsync();

            return(new Status(true, "You've successfully signed up"));
        }
コード例 #14
0
        public async Task <IActionResult> Register([FromBody] RegistrationDto userRegistrationInfo)
        {
            try
            {
                var user = new User
                {
                    Email    = userRegistrationInfo.Email,
                    UserName = userRegistrationInfo.UserName,
                    Password = userRegistrationInfo.Password,
                };

                var AlreadyExist = await _userRepository.GetUser(user.Email);

                if (AlreadyExist != null)
                {
                    return(BadRequest("User Already exists in the database"));
                }

                await _userRepository.Create(user);

                var htmlMessage = $"Thank You for joining our Open and Welcoming guitar Community <br> We hope that you enjoy your time with us and <b>Rockout</b> Hard";
                await _emailSender.SendEmailAsync(user.Email, "Account Activation", htmlMessage);

                return(Ok("Confirmation Email Sent to " + user.Email));
            }
            catch (Exception e)
            {
                _ = e.Message;
            }

            return(BadRequest("User could not be added"));
        }
コード例 #15
0
        public async Task <JsonWebTokenDto> RegisterUserAsync(RegistrationDto registration)
        {
            if (registration.Password != registration.PasswordConfirmation)
            {
                throw new AuthenticationException(ExceptionMessage.NonMatchingPasswords);
            }

            JsonWebTokenDto jsonWebToken;

            _user = new Common.Models.User(registration.Username, registration.Email, registration.Timezone, registration.Locale, true);

            var userEntity = _mapper.Map <UserEntity>(_user);

            userEntity.HashedPassword = HashPassword(_user, registration.Password);
            await _storage.CreateAsync(userEntity);

            jsonWebToken = GenerateJsonWebToken(new JwtUserClaimsDto(userEntity.Id.ToString()));
            NotificationDto notification = new NotificationDto(userEntity.Id);
            // re-create registration object to avoid queueing password info
            var registrationToQueue = new RegistrationDto()
            {
                Email = registration.Email, Username = registration.Username
            };
            await _messageQueue.SendMessageAsync(registrationToQueue, "registration", queueName : _pubSlackAppQueueName);

            await _notifier.SendWelcomeNotificationAsync(notification);

            await _notifier.SendInitialFeedbackRequestNotificationAsync(notification);

            return(jsonWebToken);
        }
コード例 #16
0
        public async Task <Response <string> > Registration(RegistrationDto registrationDto)
        {
            var response = new Response <string>();

            if (_context.Users.Any(u => u.UserName == registrationDto.UserName))
            {
                response.Error = new Error($"User with email {registrationDto.Email} already exist. Please sign in");
                return(response);
            }

            if (_context.Users.Any(u => u.UserName == registrationDto.UserName))
            {
                response.Error = new Error($"User with username {registrationDto.UserName} already exist");
                return(response);
            }



            var user = new ApplicationUser()
            {
                Email     = registrationDto.Email,
                FirstName = registrationDto.FirstName,
                LastName  = registrationDto.LastName,
                UserName  = registrationDto.UserName
            };

            if (!await _context.Users.AnyAsync())
            {
                registrationDto.Role = Role.Admin;
            }

            if (!await _roleManager.RoleExistsAsync(registrationDto.Role.ToString()))
            {
                await _roleManager.CreateAsync(new IdentityRole(registrationDto.Role.ToString()));
            }

            var result = await _userManager.CreateAsync(user, registrationDto.Password);

            if (result.Errors != null && result.Errors.Any())
            {
                response.Error = new Error(result.Errors.Select(e => e.Description).Aggregate((a, b) => a + b));
                return(response);
            }
            await _userManager.AddToRoleAsync(user, registrationDto.Role.ToString());

            var token = new EmailToken()
            {
                UserId = user.Id,
                Token  = Guid.NewGuid()
            };

            await _context.EmailTokens.AddAsync(token);

            await _context.SaveChangesAsync();

            await _emailService.SendConfirmLetter(token.Token.ToString(), user.Id, user.Email);

            response.Data = user.Id;
            return(response);
        }
コード例 #17
0
        public async Task <IActionResult> Register([FromForm] RegistrationDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(Index), dto));
            }

            var user = new User(dto.UserName)
            {
                Email = dto.Email
            };

            var creationResult = await _userManager.CreateAsync(user, dto.Password);

            if (!creationResult.Succeeded)
            {
                foreach (var error in creationResult.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }

                return(View(nameof(Index), dto));
            }

            await _signInManager.SignInAsync(user, dto.RemainSignedIn);

            if (dto.ReturnUrl != null)
            {
                return(Redirect(dto.ReturnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
        }
コード例 #18
0
ファイル: UserService.cs プロジェクト: MGaden/VotingApi
        public bool AddAdminUser(long adminUserId, RegistrationDto model)
        {
            var currentUser = _UserRepository.GetUser(adminUserId);

            if (currentUser == null)
            {
                return(false);
            }

            var user = new User
            {
                UserName     = model.UserName,
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                Password     = HashGenerator.Hash(model.Password),
                Email        = model.Email,
                Mobile       = model.Mobile,
                Role         = Policies.Admin,
                CreationTime = DateTime.Now
            };

            if (_UserRepository.AddUser(user) > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #19
0
        //public MusicianExtendedDto GetMusicianOnAlbum(int albumId, int musicianId)
        //{
        //    var result = from song in DbContext.media_product
        //        join recording in DbContext.recording_party on song.recordingid equals recording.recordingid
        //        join person in DbContext.party_real on recording.partyrealid equals person.id
        //        join instrument in DbContext.party_instrumenttype on recording.instrumentcode equals instrument.code
        //        where song.packageid == albumId && person.id == musicianId
        //        group new { instrument.description_is } by new { song.title, song.id, person.fullname };

        //    var musician = new MusicianExtendedDto();

        //    foreach (var group in result)
        //    {
        //        var instrumentList = (from instrument in @group
        //                              where instrument.description_is != null
        //                              select instrument.description_is).Distinct().ToList();

        //        musician.Fullname = group.Key.fullname;
        //        musician.Songs.Add(group.Key.title, instrumentList);
        //    }
        //    return musician;
        //}


        public ICollection <MusiciansOnSongDto> GetMusiciansOnSong(int albumId, int songId)
        {
            var result = from song in DbContext.media_product
                         join recording in DbContext.recording_party on song.recordingid equals recording.recordingid
                         join person in DbContext.party_real on recording.partyrealid equals person.id
                         join instrument in DbContext.party_instrumenttype on recording.instrumentcode equals instrument.code into instrumentCheck
                         from subinstruments in instrumentCheck.DefaultIfEmpty()
                         join role in DbContext.party_partyroletype on recording.rolecode equals role.rolecode
                         where song.packageid == albumId && song.id == songId && !person.isdeleted
                         group new { song, recording, person, subinstruments, role } by new { person.id, recordingId = recording.id, person.fullname };

            var allSongs = new List <MusiciansOnSongDto>();

            foreach (var group in result)
            {
                var credits = new List <MusicianCreditsDto>();
                foreach (var e in group)
                {
                    var musicianCredits = new MusicianCreditsDto();
                    var registration    = new RegistrationDto();
                    SetAllRegistrationFields(registration, e.recording.comment, e.recording.updatedon, e.recording.updatedby, e.recording.createdon, e.recording.createdby);
                    SetAllMusicianFields(musicianCredits, registration, e.recording.id, albumId, null, e.person.fullname, e.person.id, e.subinstruments == null ? "" : e.subinstruments.description_is, e.subinstruments == null ? "" : e.subinstruments.code, e.role.rolename_is, e.recording.rolecode);
                    credits.Add(musicianCredits);
                }
                var musician = new MusiciansOnSongDto(group.Key.id, group.Key.recordingId, group.Key.fullname, null, null, credits);

                allSongs.Add(musician);
            }

            return(allSongs);
        }
コード例 #20
0
        public async Task <IActionResult> Register([FromBody] RegistrationDto register)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var appUser = new AppUser
            {
                Email          = register.Email,
                DisplayName    = register.DisplayName,
                InvitationCode = register.InvitationCode,
                UserName       = register.Email,
            };
            var result = await _userManager.CreateAsync(appUser, register.Password);

            if (!result.Succeeded)
            {
                return(BadRequest(ModelState.AddIdentityErrors(result)));
            }

            return(CreatedAtAction("LoginEmail",
                                   new LoginDto()
            {
                Email = register.Email
            }));
        }
コード例 #21
0
        public IHttpActionResult Register(RegistrationDto registrationDto)
        {
            var currentRecord = ecaseEntity.registrations.Where(x => x.email == registrationDto.email).ToList();

            if (currentRecord.Count > 0)
            {
                return(Ok("false"));
            }

            string       token    = Guid.NewGuid().ToString().Substring(0, 10);
            registration register = new registration
            {
                firstname   = registrationDto.firstName,
                lastname    = registrationDto.lastName,
                email       = registrationDto.email,
                location    = registrationDto.location,
                password    = registrationDto.password,
                accounttype = registrationDto.accountType,
                image       = "profile.png",
                status      = true,
                token       = token,
                createdon   = DateTime.Now,
                updatedon   = DateTime.Now
            };

            ecaseEntity.registrations.Add(register);
            ecaseEntity.SaveChanges();
            //SendMessageAsync(registrationDto.email, token).Wait();
            return(Ok(register));
        }
コード例 #22
0
        public async Task <IActionResult> Register([FromBody] RegistrationDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = await _userManager.FindByNameAsync(model.UserName);

            if (user != null)
            {
                return(BadRequest("This UserName already in use!"));
            }

            user = new AppUser
            {
                UserName       = model.UserName,
                LockoutEnabled = true
            };

            var registerResult = await _userManager.CreateAsync(user, model.Password);

            if (!registerResult.Succeeded)
            {
                return(BadRequest(registerResult.Errors));
            }

            return(Ok());
        }
コード例 #23
0
        public async Task <IActionResult> Post([FromBody] RegistrationDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var userIdentity = ApplicationUserMapper.RegistrationDtoToApplicationUser(dto);

            var result = await _userService.CreateUserAsync(userIdentity, dto.Password);

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

            var createCommand =
                new CreateBusinessUserCommand(Guid.NewGuid(),
                                              new IdentityId(userIdentity.Id),
                                              dto.Location,
                                              null,
                                              null,
                                              new Email(userIdentity.Email),
                                              userIdentity.FirstName,
                                              null,
                                              userIdentity.LastName);

            await _commandBus.Send(createCommand);

            return(new OkObjectResult(new ResponseObject {
                Message = "Account Created"
            }));
        }
コード例 #24
0
        public async Task <ContentResult> Post(RegistrationDto registrationDto)
        {
            try
            {
                ReturnMessage          returnmessage = new ReturnMessage(-4, "Login Failed");
                List <RegistrationDto> userlist      = new List <RegistrationDto>();
                var userToVerify = await _userManager.FindByNameAsync(registrationDto.UserName);

                if (userToVerify != null)
                {
                    // check the credentials

                    if (await _userManager.CheckPasswordAsync(userToVerify, registrationDto.Password))
                    {
                        returnmessage.msgCode = 1;
                        returnmessage.msg     = "Login Succeful";
                        var userstoreturn = _mapper.Map <RegistrationDto>(userToVerify);
                        userstoreturn.CurrentToken = GetRandomToken(userstoreturn.UserName);
                        userlist.Add(userstoreturn);
                    }
                }
                return(this.Content(returnmessage.returnMessage(new PagedResultDto <RegistrationDto>
                                                                    (userlist.AsQueryable(), 1, 1)),
                                    "application/json"));
            }
            catch (Exception ex)
            {
                return(this.Content(JsonConvert.SerializeObject(new
                {
                    msgCode = -3,
                    msg = ex.Message
                }), "application/json"));
            }
        }
コード例 #25
0
        public IHttpActionResult AddNewRegistration([FromBody] RegistrationDto registration)
        {
            var user   = base.CurrentUser();
            var result = _registrationService.AddNewRegistration(registration, user.Domain, user.LoginName, user.Site);

            return(Created("", result));
        }
コード例 #26
0
        public static bool SendEvaluation(StudentPostDto studentDto, RegistrationDto registrationDto)
        {
            var proxy = new TestProxy
            {
                Credentials = new NetworkCredential(registrationDto.TeacherLogin, registrationDto.TeacherPassword),
                UseIntTag   = true
            };

            try
            {
                var result = proxy.GetStateName(registrationDto.CourseAbbrv, registrationDto.Year,
                                                registrationDto.Sem, registrationDto.WisVariantId, studentDto.login,
                                                25, "", registrationDto.TeacherLogin,
                                                DateTime.Today, 1);
                if (result != "OK Change" && result != "NO Change")
                {
                    return(false);
                }

                return(true);
            }
            catch (XmlRpcFaultException ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(false);
        }
コード例 #27
0
        //        [TestMethod]
        public void PerformanceTest()
        {
            var reg = new RegistrationDto
            {
                Patient = new PatientDto
                {
                    PatientNo   = Guid.NewGuid().ToString(),
                    UniqueID    = Guid.NewGuid().ToString(),
                    Domain      = "renji",
                    Birthday    = DateTime.Now.AddMonths(-9),
                    IsVip       = false,
                    EnglishName = "1",
                    Gender      = "男",
                    LocalName   = "1",
                    Site        = "rjwest",
                },
                Orders = new List <OrderDto>
                {
                    new OrderDto
                    {
                        CurrentAge  = "12 Year",
                        PatientType = "门诊病人",
                        AccNo       = MockData.GetRandom(),
                        CreateTime  = DateTime.Now,
                        Domain      = "renji"
                    }
                },
                Procedures = new List <ProcedureDto>
                {
                    new ProcedureDto
                    {
                        BodyCategory  = "45床边片",
                        BodyPart      = "手",
                        BookingNotice = "",
                        Charge        = 0,
                        CheckingItem  = "手掌正斜位(右)-床边片",
                        ContrastDose  = "",
                        ContrastName  = "",
                        Domain        = "renji",
                        ExamSystem    = "其他",
                        ExposalCount  = 0,
                        FilmCount     = 1,
                        FilmSpec      = "",
                        ImageCount    = 0,
                        Modality      = "KODAK_CR",
                        ModalityType  = "CR",
                        ProcedureCode = "0724",
                        Registrar     = "4a88d04d-ade9-4621-ba2e-9c2e064d82cc",
                        RegistrarName = "test1",
                        ReportID      = null,
                        RPDesc        = "手掌正斜位(右)-床边片",
                        Status        = 20
                    }
                },
            };
            var service = Container.Resolve <IRegistrationService>();

            service.AddNewRegistration(reg, "", "", "");
        }
コード例 #28
0
 private static void SetAllRegistrationFields(RegistrationDto registration, string comment, DateTime updatedOn, string upDatedBy, DateTime createdOn, string createdBy)
 {
     registration.Comment   = comment;
     registration.UpdatedOn = updatedOn;
     registration.UpdatedBy = upDatedBy;
     registration.CreatedOn = createdOn;
     registration.CreatedBy = createdBy;
 }
コード例 #29
0
        public ActionResult Post([FromBody] RegistrationDto account)
        {
            // TODO: add validation

            this.accountService.Create(account);

            return(Created("", null));
        }
コード例 #30
0
ファイル: Mapper.cs プロジェクト: smendis/MessageLogger
 /// <summary>
 /// Maps RegistrationDto object to RegisterResponseModel object.
 /// </summary>
 /// <param name="dto">The RegistrationDto object to map.</param>
 /// <returns></returns>
 public static RegisterResponseModel RegistrationDtoToRegisterResponseModel(RegistrationDto dto)
 {
     return(new RegisterResponseModel
     {
         application_id = dto.application_id,
         display_name = dto.display_name,
         application_secret = dto.secret
     });
 }