Esempio n. 1
0
 public IHttpActionResult UpdateEmployee(int id, [FromBody] Employee employee)
 {
     if (!ModelState.IsValid)
     {
         CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, CustomLogging.ModelStatusConverter(ModelState));
         return(BadRequest(ModelState));
     }
     if (_employeeService.GetEmployeeByID(id) == null)
     {
         CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Нет такого сотрудника");
         return(NotFound());
     }
     _employeeService.UpdateEmployee(id, employee);
     return(Ok(employee));
 }
Esempio n. 2
0
        public IHttpActionResult InsertDetention([FromBody] Detention detention)
        {
            if (!ModelState.IsValid)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, CustomLogging.ModelStatusConverter(ModelState));
                return(BadRequest(ModelState));
            }

            if (_employeeService.GetEmployeeByID(detention.DetainedByEmployeeID) == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не такого сотрудника");
                return(BadRequest("Нет сотрудника"));
            }

            _detentionService.InsertDetention(detention);
            detention.DetentionID = _detentionService.LastDetention();
            return(Ok(detention));
        }