public async Task <ActionResultResponse> Insert(string tenantId, ConfigMailTempMeta configMailTempMeta) { if (!configMailTempMeta.ConfigMailTempDetailMetas.Any()) { return(new ActionResultResponse(-1, _sharedResourceService.GetString("Please enter at least one mail."))); } var configMailTempId = Guid.NewGuid().ToString(); var configMailTemp = new ConfigMailTemp { Id = configMailTempId, TenantId = tenantId, MailTempGroupId = configMailTempMeta.MailTempGroupId, Description = configMailTempMeta.Description, IsActive = configMailTempMeta.IsActive, IsDelete = configMailTempMeta.IsDelete, Type = configMailTempMeta.Type, }; var result = await _configMailTempRepository.Insert(configMailTemp); if (result <= 0) { return(new ActionResultResponse(result, _sharedResourceService.GetString("Something went wrong. Please contact with administrator."))); } var configMailTempDetails = new List <ConfigMailTempDetail>(); foreach (var configMailTempDetailMeta in configMailTempMeta.ConfigMailTempDetailMetas) { configMailTempDetails.Add(new ConfigMailTempDetail { Id = Guid.NewGuid().ToString(), TenantId = tenantId, ConfigMailTempId = configMailTemp.Id, MailId = configMailTempDetailMeta.MailId, Type = configMailTempDetailMeta.Type, }); } var resultInsertDetailSender = await _configMailTempDetailRepository.Inserts(configMailTempDetails); if (resultInsertDetailSender > 0) { return(new ActionResultResponse(resultInsertDetailSender, _resourceService.GetString("Add new ConfigMailTempDetail successful."))); } await RollbackInsert(configMailTempId); return(new ActionResultResponse(-5, _resourceService.GetString("Can not insert new ConfigMailTemp. Please contact with administrator."))); }
public async Task <int> Update(string id, ConfigMailTemp mapMailTemp) { return(await Context.SaveChangesAsync()); }
public async Task <int> Insert(ConfigMailTemp mapMailTemp) { _mapMailTempRepository.Create(mapMailTemp); return(await Context.SaveChangesAsync()); }