Exemple #1
0
        public MethodResult <Employee> AddEmployee(EmployeeBlank employee)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "INSERT INTO [employee] (oid, pid, position, salary) VALUES(@oid, @pid, @position, @salary);";
                command.Parameters.Add(new SQLiteParameter("@oid", employee.Organization.Id)
                {
                    DbType = DbType.Int32
                });
                command.Parameters.Add(new SQLiteParameter("@pid", employee.Person.Id)
                {
                    DbType = DbType.Int32
                });
                command.Parameters.Add(new SQLiteParameter("@position", employee.Position)
                {
                    DbType = DbType.String
                });
                command.Parameters.Add(new SQLiteParameter("@salary", employee.Salary)
                {
                    DbType = DbType.Decimal
                });

                var result = ExecuteNonQuery(command);
                if (!result.Success)
                {
                    return(new MethodResult <Employee>(null, result.Description));
                }

                return(new MethodResult <Employee>(new Employee(employee)));
            }
        }
Exemple #2
0
        public EmployeeBlankViewModel(Organization organization)
        {
            Blank   = new EmployeeBlank(organization);
            Persons = GetPersons(organization);

            ValidateNotEmpty(nameof(Position), Position);
            ValidateSalary();
            ValidatePerson();
        }
Exemple #3
0
        public MethodResult <Employee> AddEmployee(EmployeeBlank employee)
        {
            var result = DataBaseManager.Instance.AddEmployee(employee);

            if (result.Success && EmployeeChanged != null)
            {
                EmployeeChanged(this, new ItemChangedEventArgs <Employee>(result.Value, ItemChangedEventArgs <Employee> .ActionType.Add));
            }

            return(result);
        }
Exemple #4
0
 public Employee(EmployeeBlank blank) : this(blank.Person, blank.Organization)
 {
     Position = blank.Position;
     Salary   = blank.Salary;
     IsActive = true;
 }