public bool DissociateCustomerUser(DissociateCustomerUserEvent dissociateCustomerUser) { try { List <KafkaMessage> messages = CustomerTopics ?.Select(topic => new KafkaMessage { Key = dissociateCustomerUser.CustomerUID.ToString(), Message = new { DissociateCustomerUserEvent = dissociateCustomerUser }, Topic = topic }) ?.ToList(); var deleteQuery = string.Format("DELETE FROM md_customer_CustomerUser " + "WHERE fk_CustomerUID = {0} AND fk_UserUID = {1};", dissociateCustomerUser.CustomerUID.ToStringAndWrapWithUnhex(), dissociateCustomerUser.UserUID.ToStringAndWrapWithUnhex()); var actions = new List <Action> { () => transaction.Delete(deleteQuery), () => transaction.Publish(messages) }; return(transaction.Execute(actions)); } catch (Exception ex) { logger.LogError($"Error while dissociating user for customer : {ex.Message}, {ex.StackTrace}"); throw; } }
public bool?DeleteUserPreference(DeleteUserPreferenceEvent userPreference) { var dbUserPreference = GetUserPreference(userPreference.UserUID, userPreference.PreferenceKeyUID, userPreference.PreferenceKeyName); if (dbUserPreference == null) { return(null); } var deleteQuery = string.Format( "Delete from md_preference_PreferenceUser where fk_UserUID = {0} and fk_PreferenceKeyID = {1}", userPreference.UserUID.ToStringAndWrapWithUnhex(), dbUserPreference.fk_PreferenceKeyID); var kafkaMessage = new KafkaMessage() { Key = userPreference.UserUID.ToString(), Message = userPreference }; var actions = new List <Action>(); actions.Add(() => transaction.Delete(deleteQuery)); actions.Add(() => topics.ToList().ForEach(topic => { kafkaMessage.Topic = topic; transaction.Publish(kafkaMessage); })); return(transaction.Execute(actions)); }
public IActionResult ContactUsDelete(int id) { #region FunctionBody ContactUs data = _db.ContactUss.Find(id); if (data == null) { return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound"))); } ContactUsDTO dto = new ContactUsDTO { Id = id, Adress = data.Adress, Email = data.Email, Phone = data.Phone, Content = data.Content, LanguageId = data.LanguageId }; bool request = _wwd.Delete(dto); if (request) { return(Ok(new ReturnMessage(200, message: "Success"))); } return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, message: "Internal server error"))); #endregion }
private void PersistAndPublishWeeklySettings(List <AssetSettingsGetDBResponse> assetSettingsGetDBResponses) { var currentDateTime = DateTime.UtcNow; var deleteSettings = assetSettingsGetDBResponses.Where(x => x.OperationType == AssetSettingsOperationType.Delete).ToList(); var upsertSettings = assetSettingsGetDBResponses.Where(x => x.OperationType == AssetSettingsOperationType.Insert || x.OperationType == AssetSettingsOperationType.Update).ToList(); List <Action> actions = new List <Action>(); //delete query if (deleteSettings.Count > 0) { var deleteWeeklySettings = this.BuildAssetWeeklySettings(deleteSettings, currentDateTime); actions.Add(() => _transactions.Delete(deleteWeeklySettings)); } //upsert query if (upsertSettings.Count > 0) { var upsertWeeklySettingsList = this.BuildAssetWeeklySettings(upsertSettings, currentDateTime); actions.Add(() => _transactions.Upsert <AssetWeeklySettingsDto>(upsertWeeklySettingsList)); } List <AssetWeeklyTargetsDto> targetsDto = new List <AssetWeeklyTargetsDto>(); foreach (var value in assetSettingsGetDBResponses) { targetsDto.Add(new AssetWeeklyTargetsDto { AssetTargetUID = Guid.Parse(value.AssetWeeklyConfigUID), AssetUID = value.AssetUID, EndDate = value.EndDate, StartDate = value.StartDate, TargetType = (AssetTargetType)Enum.Parse(typeof(AssetTargetType), value.ConfigType), SundayTargetValue = value.Sunday, MondayTargetValue = value.Monday, TuesdayTargetValue = value.Tuesday, WednesdayTargetValue = value.Wednesday, ThursdayTargetValue = value.Thursday, FridayTargetValue = value.Friday, SaturdayTargetValue = value.Saturday, Status = value.Status }); } actions.Add(() => _assetSettingsPublisher.publishAssetWeeklySettings(targetsDto)); if (actions.Count > 0) { _transactions.Execute(actions); } }
public IActionResult DeleteOnlineQuery(int Id) { #region FunctionBody var onlineQuery = _onlineQueryService.Get(Id); if (onlineQuery == null) { return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound))); } bool IsSucceed = _onlineQueryService.Delete(onlineQuery); if (!IsSucceed) { return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, code: 500))); } return(Ok(new ReturnMessage())); #endregion }
public IActionResult ServicesDelete(int id) { bool datafound = _db.ServiceInfos.Any(t => t.Id == id); if (!datafound) { return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound"))); } ServiceInfo data = _db.ServiceInfos.Find(id); bool request = _wwd.Delete(data); if (request) { return(Ok(new ReturnMessage(200, message: "Success"))); } return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, message: "Internal server error"))); }
public bool DeleteAccount(Guid customerAccountUid, DateTime actionUtc, DbAccount accountDetails) { try { var message = new KafkaMessage { Key = customerAccountUid.ToString(), Topic = AccountTopic, Message = new { AccountEvent = new AccountEvent { AccountName = accountDetails.AccountName, AccountUID = customerAccountUid, Action = Operation.Delete.ToString(), BSSID = accountDetails.BSSID, DealerAccountCode = accountDetails.DealerAccountCode, NetworkCustomerCode = accountDetails.NetworkCustomerCode, fk_ParentCustomerUID = null, fk_ChildCustomerUID = null, ActionUTC = actionUtc, ReceivedUTC = DateTime.UtcNow } } }; var deleteQuery = string.Format("DELETE FROM md_customer_CustomerAccount " + "WHERE CustomerAccountUID = {0};", customerAccountUid.ToStringAndWrapWithUnhex()); var actions = new List <Action>() { () => transaction.Delete(deleteQuery), () => transaction.Publish(message) }; return(transaction.Execute(actions)); } catch (Exception ex) { logger.LogError($"Error while deleting customer account : {ex.Message}, {ex.StackTrace}"); throw; } }
public virtual bool DeleteAssetOwnerEvent(AssetOwnerEvent assetOwnerEvent) { string guid = assetOwnerEvent.AssetUID.Value.ToStringWithoutHyphens(); string query = $"delete from md_asset_AssetOwner where {MySql.ColumnName.AssetOwner.ColumnName.ASSET_UID} = {guid.WrapWithUnhex()}"; Guid? customerUid = assetOwnerEvent.AssetOwnerRecord.CustomerUID == null || assetOwnerEvent.AssetOwnerRecord.CustomerUID == Guid.Empty ? (Guid?)null : assetOwnerEvent.AssetOwnerRecord.CustomerUID; Guid? accountUid = assetOwnerEvent.AssetOwnerRecord.AccountUID == null || assetOwnerEvent.AssetOwnerRecord.AccountUID == Guid.Empty ? (Guid?)null : assetOwnerEvent.AssetOwnerRecord.AccountUID; DateTime utcNow = DateTime.UtcNow; var message = new KafkaMessage { Key = assetOwnerEvent.AssetUID.ToString(), Message = new { AssetUID = assetOwnerEvent.AssetUID, AssetOwnerRecord = new ClientModel.AssetOwner { CustomerName = assetOwnerEvent.AssetOwnerRecord.CustomerName, AccountName = assetOwnerEvent.AssetOwnerRecord.AccountName, DealerAccountCode = assetOwnerEvent.AssetOwnerRecord.DealerAccountCode, DealerUID = assetOwnerEvent.AssetOwnerRecord.DealerUID, DealerName = assetOwnerEvent.AssetOwnerRecord.DealerName, NetworkCustomerCode = assetOwnerEvent.AssetOwnerRecord.NetworkCustomerCode, NetworkDealerCode = assetOwnerEvent.AssetOwnerRecord.NetworkDealerCode, CustomerUID = customerUid, AccountUID = accountUid }, Action = "Delete", ActionUTC = utcNow, //ToDO: Ensure the Insert UTC values ReceivedUTC = utcNow } }; var actions = new List <Action>() { () => _transaction.Delete(query), () => assetOwnerTopicNames?.ForEach((topic) => { message.Topic = topic; _transaction.Publish(message); }) }; return(_transaction.Execute(actions)); }
public bool DissociateAssetDevice(DissociateDeviceAssetEvent dissociateDeviceAsset) { var kafkaMessageList = new List <KafkaMessage>(); dissociateDeviceAsset.ReceivedUTC = DateTime.UtcNow; kafkaTopicNames.ForEach(topic => { KafkaMessage kafkaMessage = new KafkaMessage() { Key = dissociateDeviceAsset.DeviceUID.ToString(), Message = new { DissociateDeviceAssetEvent = dissociateDeviceAsset }, Topic = topic }; kafkaMessageList.Add(kafkaMessage); }); var actions = new List <Action>(); actions.Add(() => transactions.Delete($"DELETE FROM md_asset_AssetDevice WHERE fk_AssetUID={dissociateDeviceAsset.AssetUID.ToStringWithoutHyphens().WrapWithUnhex()} AND fk_DeviceUID={dissociateDeviceAsset.DeviceUID.ToStringWithoutHyphens().WrapWithUnhex()}")); actions.Add(() => transactions.Publish(kafkaMessageList)); return(transactions.Execute(actions)); }
public virtual bool DeleteAsset(DeleteAssetPayload asset) { string guid = asset.AssetUID.Value.ToStringWithoutHyphens(); DateTime actionUTC = DateTime.UtcNow; string query = $"update md_asset_Asset set StatusInd = 0, UpdateUTC = '{actionUTC.ToString("yyyy-MM-dd HH:mm:ss.ffffff")}' where AssetUID = {guid.WrapWithUnhex()}"; //Kafka message asset.ActionUTC = actionUTC; var message = new KafkaMessage { Key = asset.AssetUID.ToString(), Message = new { DeleteAssetEvent = asset } }; var actions = new List <Action>() { () => _transaction.Delete(query), () => assetTopicNames?.ForEach((topic) => { message.Topic = topic; _transaction.Publish(message); }) }; return(_transaction.Execute(actions)); }
public IActionResult WhatWeDoDelete(int id) { bool datafound = _db.WhatWeDos.Any(t => t.Id == id); if (!datafound) { return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound"))); } WhatWeDo data = _db.WhatWeDos.Find(id); WhatWeDoDTO dto = new WhatWeDoDTO { Id = id, Content = data.Content, LanguageId = data.LanguageId }; bool request = _wwd.Delete(dto); if (request) { return(Ok(new ReturnMessage(200, message: "Success"))); } return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, message: "Internal server error"))); }
public IActionResult OurServicesDelete(int id) { bool datafound = _db.Services.Any(t => t.Id == id); if (!datafound) { return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound"))); } Service data = _db.Services.Find(id); OurServicesDTO dto = new OurServicesDTO { Id = id, Name = data.Name, LanguageId = data.LanguageId }; bool request = _wwd.Delete(dto); if (request) { return(Ok(new ReturnMessage(200, message: "Success"))); } return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, message: "Internal server error"))); }