コード例 #1
0
 public static Models.Trainers.Trainer fromDb(Database.Trainer dbTrainer)
 {
     return(new Models.Trainers.Trainer
     {
         Address = dbTrainer.AppUser.Address,
         Status = (Models.Requests.UserStatus)(int) dbTrainer.AppUser.Status,
         CreatedAt = dbTrainer.AppUser.CreatedAt.ToString("dd-MM-yyyy"),
         Email = dbTrainer.AppUser.Email,
         FirstName = dbTrainer.AppUser.FirstName,
         LastName = dbTrainer.AppUser.LastName,
         Id = dbTrainer.AppUser.Id,
         PhoneNumber = dbTrainer.AppUser.PhoneNumber
     });
 }
コード例 #2
0
        public Models.Trainers.Trainer Create(CreateTrainerRequest createTrainerRequest)
        {
            Database.AppUser appUser = _mapper.Map <Database.AppUser>(createTrainerRequest);
            appUser.HashedPassword = HashUtil.ComputeSha256Hash(createTrainerRequest.Password);
            appUser.CreatedAt      = DateTime.UtcNow;
            appUser.Status         = Database.UserStatus.ACTIVE;

            // add trainer specific data
            Database.Trainer trainer = new Database.Trainer();
            appUser.Trainer = trainer;

            _context.AppUsers.Add(appUser);
            _context.SaveChanges();
            return(_mapper.Map <Models.Trainers.Trainer>(appUser));
        }