public async Task<JsonResult> SetWorker(Worker worker)
        {
            int persent = 10;
            if (worker.Tasso > 10000 && worker.Tasso <= 25000)
                persent = 15;
            if (worker.Tasso > 25000)
                persent = 25;

            context.Workmen.Add(new Workman{
                FirstName = worker.FirstName,
                LastName = worker.LastName,
                Position = worker.Position,
                Status = worker.Status,
                Tasso = worker.Tasso,
                TaxRate = persent,
                Tax = worker.Tasso/100*persent,
                Wages = worker.Tasso - worker.Tasso / 100 * persent
            });
            await context.SaveChangesAsync();
            return Json("Данные сохранены");
        }
Beispiel #2
0
        public async void VerifyingSetUser()
        {
            TestDbContext context = new TestDbContext();
            EmployeesController employeecontroller = new EmployeesController(context, null);
  
            Worker worker = new Worker
            {
                FirstName = "Fworkername",
                LastName = "Lworkername",
                Position = "SomeJobs",
                Status = true,
                Tasso = 10000
            };
            await employeecontroller.SetWorker(worker);
            Workman workman = context.Workmen.FirstOrDefault();
            
            Assert.Equal("Fworkername", workman.FirstName);
            Assert.True(workman.Tax == 1000);
            Assert.True(workman.TaxRate == 10);
            Assert.True(workman.Wages == 9000);

            context.Dispose();
        }