public IActionResult Index(SubmitExpense model)
        {
            Btsexpenses expenses = new Btsexpenses();

            expenses.ClaimId              = model.ApprovedClaimId;
            expenses.ExpenseAmount        = model.Amount;
            expenses.ExpenseCategoryId    = model.CategoryId;
            expenses.ExpenseStartDate     = model.StartDate;
            expenses.ExpenseEndDate       = model.EndDate;
            expenses.ExpenseSubCategoryId = model.SubCategoryId;
            expenses.LastModifiedBy       = DateTime.Now;
            expenses.StatusId             = 1;
            expenses.CurrencyType         = model.CurrencyId;
            _context.Btsexpenses.Add(expenses);
            _context.SaveChanges();
            if (model.Attachment.Length > 0)
            {
                var fileName = model.Attachment.FileName;
                var filePath = "wwwroot\\Files\\";
                using (var stream = new FileStream(filePath + fileName, FileMode.Create))
                {
                    model.Attachment.CopyTo(stream);
                    Attachments attachment = new Attachments();
                    attachment.FilePath = filePath;
                    attachment.FileName = fileName;
                    attachment.Expense  = expenses;
                    _context.Attachments.Add(attachment);
                    _context.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }
Пример #2
0
 public SubmitExpenseText()
 {
     _repository = new Mock <IExpenseRepository>();
     _useCase    = new SubmitExpense(_repository.Object);
 }