public async Task <OperationResult> AddEformToGroup(EformBindGroupModel requestModel) { try { if (!await _dbContext.SecurityGroups.AnyAsync(x => x.Id == requestModel.GroupId)) { return(new OperationResult(false, _localizationService.GetString("SecurityGroupNotFound"))); } if (await _dbContext.EformInGroups.AnyAsync(x => x.TemplateId == requestModel.EformId && x.SecurityGroupId == requestModel.GroupId)) { return(new OperationResult(false, _localizationService.GetString("eFormAlreadyInGroup"))); } var newEformInGroup = new EformInGroup() { SecurityGroupId = requestModel.GroupId, TemplateId = requestModel.EformId }; await _dbContext.EformInGroups.AddAsync(newEformInGroup); await _dbContext.SaveChangesAsync(); return(new OperationResult(true)); } catch (Exception e) { Console.WriteLine(e); _logger.LogError(e.Message); return(new OperationResult(true, _localizationService.GetString("ErrorWhileBindingEformToGroup"))); } }
public async Task <OperationResult> AddEformToGroup([FromBody] EformBindGroupModel model) { return(await _eformGroupService.AddEformToGroup(model)); }