예제 #1
0
        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!"
                    });
                }
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        public async Task <ResultModel> Add(TimekeepingTransactionModel model)
        {
            var result = await _httpClient.PostAsJsonAsync($"api/timekeepingtransaction", model).Result.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <ResultModel>(result));
        }
예제 #4
0
 public async Task <ActionResult> AddEmployee(TimekeepingTransactionModel model)
 {
     return(Ok(await _timeKeepingTransactionService.Add(model)));
 }