public EditClientViewModel(DAL.Models.Authentication.Client client) { ClientId = client.ClientId; ClientAppId = client.ClientAppId; Secret = string.Empty; Name = client.Name; WebApiApplicationTypes tmpWebApiApplicationTypes; Enum.TryParse <WebApiApplicationTypes>(client.WebApiApplicationTypes, out tmpWebApiApplicationTypes); this.WebApiApplicationTypes = tmpWebApiApplicationTypes; WebApiApplicationDataAccessTypes tmpWebApiApplicationDataAccessTypes; Enum.TryParse <WebApiApplicationDataAccessTypes>(client.WebApiApplicationDataAccessTypes, out tmpWebApiApplicationDataAccessTypes); this.WebApiApplicationDataAccessTypes = tmpWebApiApplicationDataAccessTypes; ClientStatusEnum tmpStatus; Enum.TryParse <ClientStatusEnum>(client.Status, out tmpStatus); this.Status = tmpStatus; RefreshTokenLifeTime = client.RefreshTokenLifeTime; AccessTokenLifeTime = client.AccessTokenLifeTime; AllowedOrigin = client.AllowedOrigin; }
public ClientViewModel(DAL.Models.Authentication.Client client) { ClientId = client.ClientId; Name = client.Name; WebApiApplicationTypes = client.WebApiApplicationTypes; WebApiApplicationDataAccessTypes = client.WebApiApplicationDataAccessTypes; Status = client.Status; RefreshTokenLifeTime = client.RefreshTokenLifeTime; AccessTokenLifeTime = client.AccessTokenLifeTime; AllowedOrigin = client.AllowedOrigin; }
public async Task CreateClient(CreateClientViewModel model, string userId, string username) { try { var tempApp = unitOfWork.ClientRepository.GetAllQueryable() .Where(x => x.ClientAppId == model.ClientAppId) .ToList(); if (tempApp != null && tempApp.Count > 0) { throw new ValidationException("Aplication with this Client app id already exist."); } DAL.Models.Authentication.Client client = new DAL.Models.Authentication.Client(); client.ClientAppId = model.ClientAppId; client.AllowedOrigin = model.AllowedOrigin; client.CreatedById = userId; client.CreatedByUsername = username; client.DateCreated = DateTime.UtcNow; client.Name = model.Name; client.RefreshTokenLifeTime = model.RefreshTokenLifeTime; client.AccessTokenLifeTime = model.AccessTokenLifeTime; client.Secret = AuthHelper.GetHash(model.Secret); client.Status = model.Status.ToString();; client.WebApiApplicationDataAccessTypes = model.WebApiApplicationDataAccessTypes.ToString(); client.WebApiApplicationTypes = model.WebApiApplicationTypes.ToString(); unitOfWork.ClientRepository.Create(client); await unitOfWork.SaveChangesAsync(); } catch (Exception e) { await LogError("CreateClient", e); Trace.TraceError("CreateClient in webapi service error : {0}", e.Message); throw e; } }