/// <summary>
        /// Удаление отделения.
        /// </summary>
        /// <param name="department">Отделение, которое следует удалить.</param>
        public async void Delete(IEntity department)
        {
            ID = department.ID;

            DataServiceStub ds = new DataServiceStub();
            await ds.DeleteDepartment(this);
        }
        /// <summary>
        /// Добавление нового отделения.
        /// </summary>
        /// <param name="department">Отделение, которое следует добавить.</param>
        public async void Insert(IEntity department)
        {
            ID       = department.ID;
            DeptName = (department as Department).DeptName;
            DeptInfo = (department as Department).DeptInfo;

            DataServiceStub ds = new DataServiceStub();
            await ds.InsertDepartment(this);
        }
 /// <summary>
 /// Удаление отделения из БД.
 /// </summary>
 /// <param name="department">Отделение, которое следует удалить из БД.</param>
 /// <returns>Статус выполнения запроса</returns>
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         DataServiceStub ds = new DataServiceStub();
         ds.DeleteDepartment(id);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 /// <summary>
 /// Добавление нового отделения в БД.
 /// </summary>
 /// <param name="department">Отделение, которое следует добавить в БД.</param>
 /// <returns>Статус выполнения запроса</returns>
 public HttpResponseMessage Post([FromBody] Department department)
 {
     try
     {
         DataServiceStub ds = new DataServiceStub();
         ds.InsertDepartment(department);
         return(Request.CreateResponse(HttpStatusCode.Created));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 /// <summary>
 /// Добавление нового сотрудника в БД.
 /// </summary>
 /// <param name="employee">Сотрудник, которого следует добавить.</param>
 /// <returns>Статус выполнения запроса</returns>
 public HttpResponseMessage Post([FromBody] Employee employee)
 {
     try
     {
         DataServiceStub ds = new DataServiceStub();
         ds.InsertEmployee(employee);
         return(Request.CreateResponse(HttpStatusCode.Created));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Beispiel #6
0
        /// <summary>
        /// Метод, открывающий окно Отделения.
        /// </summary>
        private void ShowDepartments()
        {
            var v = windows["DepartmentsView"];

            if (v != null)
            {
                DataServiceStub ds              = new DataServiceStub();
                Type            t               = v.GetType();
                ConstructorInfo ctor            = t.GetConstructor(Type.EmptyTypes);
                PropertyInfo    propDataContext = t.GetProperty("DataContext");
                if (propDataContext != null)
                {
                    object instance = ctor.Invoke(null);
                    propDataContext.SetValue(instance, new DepartmentsViewModel(new EmployersModel(ds), new DepartmentsModel(ds)));
                    PropertyInfo propOwner = t.GetProperty("Owner");
                    propOwner.SetValue(instance, mainWindow);
                    MethodInfo methodShow = t.GetMethod("Show");
                    methodShow.Invoke(instance, null);
                }
            }
        }
Beispiel #7
0
 public ProjectsModel()
 {
     _projects = new DataServiceStub().GetProjects();
 }