Ejemplo n.º 1
0
 public async Task <IActionResult> Register(UserModel model)
 {
     try
     {
         var roles = _rolesService.GetRolesClient();
         if (roles == null)
         {
             _logger.LogError("Roles Null");
         }
         model.RolesId = roles.Id;
         var id = Guid.NewGuid();
         _userClientService.CreatedUserCliet(model, id);
         _emailSenderService.SendEmail(model.Email, Constants.SubjectCreatedAccount, Constants.BodyCreatedAccount);
         Statistics statistics = new Statistics()
         {
             Action      = (int)Action.CreatedUser,
             ActionName  = "Đăng ký tài khoản",
             CreatedDate = DateTime.Now,
             Id          = Guid.NewGuid(),
             ModifyDate  = DateTime.Now
         };
         _statisticsService.InsertStatistics(statistics);
         var userInfor = new UserInfor()
         {
             Address  = model.Address,
             BirthDay = model.Birthday,
             Gender   = model.Gender,
             UserId   = id
         };
         _userInfroService.CreatedUserInfor(userInfor);
         return(Ok(new Result()
         {
             Code = (int)HttpStatusCode.OK, Data = null, Error = "Tạo tài khoản thành công"
         }));
     }
     catch (Exception ex)
     {
         _logger.LogError("Lỗi tạo tài khoản: " + ex);
         return(Ok(new Result()
         {
             Code = (int)HttpStatusCode.InternalServerError, Data = null, Error = "Lỗi tạo tài khoản"
         }));
     }
 }