public ActionResult Register(CustomerItem customer) { var objr = new CustomerAppItem { Status = 0 }; try { if (!string.IsNullOrEmpty(customer.Phone) && !string.IsNullOrEmpty(customer.Password)) { if (_da.CheckUserName(customer.Phone)) { return(Json(new BaseResponse <CustomerItem>() { Erros = true, Message = "Số điện thoại đã tồn tại", }, JsonRequestBehavior.AllowGet)); } var daten = DateTime.Now; var date = daten.TotalSeconds(); var saltKey = FDIUtils.CreateSaltKey(5); var sha1PasswordHash = FDIUtils.CreatePasswordHash(customer.Password, saltKey); //get agencyinfo var agencyDA = new AgencyDA(); var agency = agencyDA.GetItem(customer.PhoneAgency); var obj = new Base.Customer { FullName = customer.FullName, Phone = customer.Phone, PasswordSalt = saltKey, PassWord = sha1PasswordHash, UserName = customer.UserName, DateCreated = date, IsDelete = false, IsActive = true, Reward = 0, AgencyID = agency?.ID }; _da.Add(obj); _da.Save(); IAuthContainerModel model = new JWTContainerModel() { Claims = new Claim[] { new Claim(ClaimTypes.Name, obj.UserName), new Claim("ID", obj.ID.ToString()), } }; IAuthService authService = new JWTService(); var token = authService.GenerateToken(model); var result = new BaseResponse <CustomerItem>() { Erros = false, Data = new CustomerItem() { FullName = obj.FullName, Phone = obj.Phone, Token = token } }; return(Json(result, JsonRequestBehavior.AllowGet)); var datee = daten.AddDays(5).TotalSeconds(); //var lg = new Ultils(); var code = Ultils.CodeLogin(daten); var dNlogin = new DN_Login { CustomerID = obj.ID, DateCreated = date, DateEnd = datee, Code = code, IsOut = false }; _dl.Add(dNlogin); _dl.Save(); objr = new CustomerAppItem { ID = obj.ID, Status = 1, }; } } catch (Exception ex) { Log2File.LogExceptionToFile(ex); } return(Json(objr, JsonRequestBehavior.AllowGet)); }