public async Task <BaseComponentResultRp> CreateMember(MemberPostRp model) { var result = new BaseComponentResultRp(); var createdBy = this._identityGateway.GetIdentity(); var squad = await this._dbContext.Squads.SingleAsync(c => c.Id == model.SquadId); var user = await this._dbContext.Users.SingleAsync(c => c.Id == model.UserId); var entity = MemberEntity.Factory.Create(squad.Id.Value, user.Id.Value, this._datetimeGateway.GetCurrentDateTime(), createdBy); this._dbContext.Members.Add(entity); await this._dbContext.SaveChangesAsync(); result.AddResult("Id", entity.Id); return(result); }
public async Task <BaseComponentResultRp> CreateSquadProduct(SquadProductPostRp model) { var result = new BaseComponentResultRp(); var createdBy = this._identityService.GetIdentity(); var squad = await this._dbContext.Squads.SingleAsync(c => c.Id == model.SquadId); var Product = await this._dbContext.Products.SingleAsync(c => c.Id == model.ProductId); var entity = SquadProductEntity.Factory.Create(squad, Product, this._datetimeGateway.GetCurrentDateTime(), createdBy); this._dbContext.SquadProducts.Add(entity); await this._dbContext.SaveChangesAsync(); result.AddResult("Id", entity.Id); return(result); }
/// <summary> /// Create a new appsetting /// </summary> /// <param name="model">AppSetting Model</param> /// <returns></returns> public async Task <BaseComponentResultRp> CreateAppSetting(AppSettingPostRp model) { var result = new BaseComponentResultRp(); var createdBy = this._identityGateway.GetIdentity(); var appSetting = AppSettingEntity.Factory.Create(model.Key, model.Value, true, DateTime.UtcNow, createdBy); var entity = await this._dbContext.AppSettings.FirstOrDefaultAsync(c => c.Key.Equals(model.Key)); if (entity != null) { result.AddConflict($"The Key {model.Key} has already been taken."); return(result); } await this._dbContext.AddAsync(appSetting); await this._dbContext.SaveChangesAsync(); result.AddResult("Key", appSetting.Key); return(result); }
/// <summary> /// Create a new appsetting /// </summary> /// <param name="model">AppSetting Model</param> /// <returns></returns> public async Task <BaseComponentResultRp> CreateAppSetting(AppSettingPostRp model) { var result = new BaseComponentResultRp(); var createdBy = this._identityService.GetIdentity(); var appSetting = AppSettingEntity.Factory.Create(model.Key, model.Value, true, createdBy); var entity = await this._appSettingRepository.GetAppSettingByKey(model.Key); if (entity != null) { result.AddConflict($"The Key {model.Key} has already been taken."); return(result); } this._appSettingRepository.Add(appSetting); await this._appSettingRepository.SaveChanges(); result.AddResult("Key", appSetting.Key); return(result); }