public CommonResponse <TicketStatusVM> UpdateData(TicketStatusVM data, TableTransactionVM transaction) { CommonResponse <TicketStatusVM> result; using Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction dbTransaction = DbContext.Database.BeginTransaction(); try { string transactionId = TransactionRepository.InitializeTransaction(transaction); result = TicketStatusRepository.UpdateData(data, transactionId); dbTransaction.Commit(); } catch (Exception e) { Logger.LogError("Error Updating TicketStatus Data by IP Address {0} : {1}\nInner Ex : {2}", transaction?.IpAddress ?? "", e.Message ?? "", e.InnerException?.Message ?? "" ); result = new CommonResponse <TicketStatusVM> { Status = false, Code = "E-003", Message = "Update Data Failed! Please Contact an Web Administrator!", Data = new TicketStatusVM[] { data }, }; } return(result); }
public CommonResponse <TicketStatusVM> DeleteData([FromBody] TicketStatusVM data) { string myUserId = User.FindFirst(ClaimTypes.Name)?.Value; TableTransactionVM transaction = new TableTransactionVM { IpAddress = HttpContext.Connection.RemoteIpAddress.ToString(), UserId = myUserId, }; return(TicketStatusServices.DeleteData(data, transaction)); }