示例#1
0
        public async Task <ManagerResponseDto> PostResponses(ManagerResponseDto managerResponseDto)
        {
            var employee = await Context.TaxExemptions.FirstOrDefaultAsync(x => x.Username == managerResponseDto.Username);

            var response = new Response
            {
                Username = managerResponseDto.Username,
                Name     = managerResponseDto.Name,
                Food     = managerResponseDto.Food,
                Fuel     = managerResponseDto.Fuel,
                Hra      = managerResponseDto.Hra,
                Travel   = managerResponseDto.Travel,
                Comments = managerResponseDto.Comments
            };

            if (managerResponseDto.Food == "accept" && managerResponseDto.Fuel == "accept" && managerResponseDto.Hra == "accept" && managerResponseDto.Travel == "accept")
            {
                var final = new FinalTax
                {
                    Username     = employee.Username,
                    Name         = employee.Name,
                    FoodAmount   = employee.FoodAmount,
                    FuelAmount   = employee.FuelAmount,
                    HraAmount    = employee.HraAmount,
                    TravelAmount = employee.TravelAmount
                };

                await Context.FinalTaxes.AddAsync(final);
            }

            Context.TaxExemptions.Remove(employee);
            await Context.Responses.AddAsync(response);

            await Context.SaveChangesAsync();

            return(managerResponseDto);
        }
示例#2
0
        public async Task <IActionResult> PostResponse(ManagerResponseDto managerResponseDto)
        {
            var result = await Repo.PostResponses(managerResponseDto);

            return(StatusCode(201));
        }