<commit_before>﻿using System.Collections.Generic;

using MAutoSS.DataModels;
using MAutoSS.Data.Repositories.Contracts;
using MAutoSS.Services.Contracts;
using System;

namespace MAutoSS.Services
{
    public class EmployeeService : IEmployeeService
    {
        private IGenericRepository<Employee> employeeRepo;
        private IGenericRepository<Dealership> dealershipRepo;
        private IDealershipService dealershipService;

        public EmployeeService(
            IGenericRepository<Employee> employeeRepo, 
            IGenericRepository<Dealership> dealershipRepo,
            IDealershipService dealershipService)
        {
            this.employeeRepo = employeeRepo;
            this.dealershipRepo = dealershipRepo;
            this.dealershipService = dealershipService;
        }

        IEnumerable<Employee> IEmployeeService.GetAllEmployees()
        {
            return this.employeeRepo.GetAll();
        }

        public void CreateNewEmployee(string firstName, string lastName, string dealershipName)
        {
            var dealershipToAssignEmployee = this.dealershipService.GetDealershipByName(dealershipName);

            var newEmployee = new Employee
            {
                FirstName = firstName,
                LastName = lastName,
                DealershipId = dealershipToAssignEmployee.Id
            };
            
            this.employeeRepo.Add(newEmployee);
            this.employeeRepo.SaveChanges();


        
        }
    }
}
<commit_msg>Add Bytes2You validation to EmployeeService.<commit_after>﻿using System.Collections.Generic;

using MAutoSS.DataModels;
using MAutoSS.Data.Repositories.Contracts;
using MAutoSS.Services.Contracts;
using Bytes2you.Validation;

namespace MAutoSS.Services
{
    public class EmployeeService : IEmployeeService
    {
        private IGenericRepository<Employee> employeeRepo;
        private IGenericRepository<Dealership> dealershipRepo;
        private IDealershipService dealershipService;

        public EmployeeService(
            IGenericRepository<Employee> employeeRepo, 
            IGenericRepository<Dealership> dealershipRepo,
            IDealershipService dealershipService)
        {
            Guard.WhenArgument(employeeRepo, "employeeRepo").IsNull().Throw();
            Guard.WhenArgument(dealershipRepo, "dealershipRepo").IsNull().Throw();
            Guard.WhenArgument(dealershipService, "dealershipService").IsNull().Throw();
            
            this.employeeRepo = employeeRepo;
            this.dealershipRepo = dealershipRepo;
            this.dealershipService = dealershipService;
        }

        IEnumerable<Employee> IEmployeeService.GetAllEmployees()
        {
            return this.employeeRepo.GetAll();
        }

        public void CreateNewEmployee(string firstName, string lastName, string dealershipName)
        {
            var dealershipToAssignEmployee = this.dealershipService.GetDealershipByName(dealershipName);

            var newEmployee = new Employee
            {
                FirstName = firstName,
                LastName = lastName,
                DealershipId = dealershipToAssignEmployee.Id
            };
            
            this.employeeRepo.Add(newEmployee);
            this.employeeRepo.SaveChanges();        
        }
    }
}

{'fraction_non_alphanumeric': 0.06849728424864213, 'fraction_numerical': 0.0006035003017501509, 'mean_word_length': 2.4104938271604937, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '516739', 'n_tokens_mistral': 862, 'n_tokens_neox': 811, 'n_words': 142}