public async Task CreatePostionThatAlreadyExist_ShouldReturnDefault()
        {
            this.Initialize();
            this.SeedPositions();

            var input1 = new CreateJobPositionInputModel()
            {
                Name   = PositionName,
                Salary = Salary
            };

            var input2 = new CreateJobPositionInputModel()
            {
                Name   = PositionName + 1,
                Salary = Salary + 1
            };

            var input3 = new CreateJobPositionInputModel()
            {
                Name   = PositionName + 9,
                Salary = Salary + 9
            };

            var rowsExpectedToAdd = 0;
            var addedCount1       = await this.service.CreateAsync(input1);

            var addedCount2 = await this.service.CreateAsync(input2);

            var addedCount3 = await this.service.CreateAsync(input3);

            Assert.Equal(rowsExpectedToAdd, addedCount1);
            Assert.Equal(rowsExpectedToAdd, addedCount2);
            Assert.Equal(rowsExpectedToAdd, addedCount3);
        }
        public async Task <int> CreateAsync(CreateJobPositionInputModel model)
        {
            var doesExist = await this.context
                            .Positions
                            .AnyAsync(x => x.Name == model.Name);

            if (doesExist)
            {
                return(default);
        public async Task <IActionResult> Create(CreateJobPositionInputModel model)
        {
            var rowsCreated = await this.positionService.CreateAsync(model);

            if (rowsCreated != WebConstants.OneRow)
            {
                return(this.BadRequest());
            }

            return(this.Redirect(WebConstants.AdminHomePage));
        }
        public async Task CreateNewPosition_ShouldReturnOneRowAdded(string positionName, decimal salary)
        {
            this.Initialize();

            var input = new CreateJobPositionInputModel()
            {
                Name   = positionName,
                Salary = salary
            };

            var rowsExpectedToAdd = 1;
            var addedCount        = await this.service.CreateAsync(input);

            Assert.Equal(rowsExpectedToAdd, addedCount);
        }