public async Task <ResultModel> Add(TimekeepingTransactionModel model) { using (_dbContext) { using (var tranScope = await _dbContext.Database.BeginTransactionAsync()) { TimekeepingTransaction timekeepingTransaction; _dbContext.TimekeepingTransactions.Add(timekeepingTransaction = new TimekeepingTransaction { EmployeeId = model.EmployeeId, TransactionTypeId = model.TransactionTypeId, TransactionDateTime = DateTime.Now }); await _dbContext.SaveChangesAsync(); tranScope.Commit(); return(new ResultModel { IsSuccessful = true, Data = timekeepingTransaction, Message = "Transaction successfully created!" }); } } }
public async void TimeOut() { if (!string.IsNullOrEmpty(SelectedEmployeeId)) { var tkTransactionModel = new TimekeepingTransactionModel() { EmployeeId = int.Parse(SelectedEmployeeId), TransactionDateTime = DateTime.Now, TransactionTypeId = 2 //Time Out }; var result = await TimekeepingTransactionService.Add(tkTransactionModel); this.GetTransactionByEmployeeId(int.Parse(SelectedEmployeeId)); } }
public async Task <ResultModel> Add(TimekeepingTransactionModel model) { var result = await _httpClient.PostAsJsonAsync($"api/timekeepingtransaction", model).Result.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ResultModel>(result)); }
public async Task <ActionResult> AddEmployee(TimekeepingTransactionModel model) { return(Ok(await _timeKeepingTransactionService.Add(model))); }