public ResultDto Register(RegisterDto data)
{
if (data == null)
{
return new ResultDto("No data provided.");
}
using (BzsEntityContainer ctx = this.CreateContainer())
{
if (ctx.AccountSet.Count(f => f.Account == data.Account) > 0)
{
return new ResultDto("The account already exists.");
}
if (data.Account.Length > 50)
{
return new ResultDto("ERR-REG-ACCOUNT-LENGTH");
}
if (data.Password.Length > 50)
{
return new ResultDto("ERR-REG-PASSWORD-LENGTH");
}
AccountEntity entity = new AccountEntity();
entity.Id = Guid.NewGuid();
entity.Account = data.Account;
entity.Password = data.Password;
entity.Email = data.Email;
entity.ModDate = DateTime.Now;
entity.ModUser = Environment.UserName;
ctx.AccountSet.Add(entity);
ctx.SaveChanges();
return new ResultDto(true);
}
}