コード例 #1
0
        public async Task ReplaceExistingSalaryAsync(CreateSalaryViewModel model)
        {
            var existingSalary = this.salaryRepository.All()
                                 .Where(x => x.UserId == model.UserId).First();

            existingSalary.EffectiveTo = DateTime.UtcNow;

            this.salaryRepository.Update(existingSalary);
            await this.salaryRepository.SaveChangesAsync();

            await this.CreateAsync(model);
        }
コード例 #2
0
        public async Task CreateAsync(CreateSalaryViewModel model)
        {
            var salary = new Salary
            {
                Salary1     = model.Salary,
                Periodicity = model.Periodicity,
                Currency    = model.Currency,
                UserId      = model.UserId,
                CreatedOn   = DateTime.UtcNow,
                IsDeleted   = false
            };

            await this.salaryRepository.AddAsync(salary);

            await this.salaryRepository.SaveChangesAsync();
        }
コード例 #3
0
        public async Task <IActionResult> Create(CreateSalaryViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            if (model.availableSalary)
            {
                await this.salaryService.ReplaceExistingSalaryAsync(model);
            }
            else
            {
                await this.salaryService.CreateAsync(model);
            }

            return(this.RedirectToAction("Index"));
        }
コード例 #4
0
        public IActionResult Create(string employeeId)
        {
            var availableSalary = this.salaryService.CheckForSalary(employeeId);

            if (availableSalary)
            {
                var currentSalary = this.salaryService.GetSalary <CreateSalaryViewModel>(employeeId);
                currentSalary.availableSalary = availableSalary;

                return(this.View(currentSalary));
            }

            var model = new CreateSalaryViewModel {
                UserId = employeeId, availableSalary = availableSalary
            };

            return(this.View(model));
        }