public virtual void Delete(EmployeeDirectoryModel employee, ModelStateDictionary modelState)
        {
            var entity = employee.ToEntity();

            db.EmployeeDirectories.Attach(entity);

            Delete(entity);

            db.SaveChanges();
        }
        private bool ValidateModel(EmployeeDirectoryModel employee, ModelStateDictionary modelState)
        {
            if (employee.HireDate < employee.BirthDate)
            {
                modelState.AddModelError("errors", "Employee cannot be hired before birth.");
                return(false);
            }

            return(true);
        }
 public virtual void Update(EmployeeDirectoryModel employee, ModelStateDictionary modelState)
 {
     if (ValidateModel(employee, modelState))
     {
         var entity = employee.ToEntity();
         db.EmployeeDirectories.Attach(entity);
         db.Entry(entity).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
        public virtual void Insert(EmployeeDirectoryModel employee, ModelStateDictionary modelState)
        {
            if (ValidateModel(employee, modelState))
            {
                var entity = employee.ToEntity();

                db.EmployeeDirectories.Add(entity);
                db.SaveChanges();

                employee.EmployeeId = entity.EmployeeID;
            }
        }