Beispiel #1
0
        public static Employee FromViewModel(this EmployeeView model, int id = default)
        {
            if (model is null)
            {
                return(null);
            }
            var employee = new Employee {
                Id = id
            };

            model.MapTo(employee);
            return(employee);
        }
Beispiel #2
0
        public EmployeeView UpdateEmployee(int id, EmployeeView Employee)
        {
            if (Employee is null)
            {
                throw new ArgumentNullException(nameof(Employee));
            }

            var db_employee = GetById(id);

            if (db_employee is null)
            {
                throw new InvalidOperationException($"Сотрудник с идентификатором {id} не найден");
            }

            Employee.MapTo(db_employee);

            return(Employee);
        }