public HttpResponseMessage Update(HttpRequestMessage request, PartTimeEmployeeViewModel parttimeemployee)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest,
                                                      ModelState.Keys.SelectMany(k => ModelState[k].Errors)
                                                      .Select(m => m.ErrorMessage).ToArray());
                }
                else
                {
                    PartTimeEmployee _partTimeEmployee = _parttimeemployeeRepository.GetSingle(parttimeemployee.ID);
                    _partTimeEmployee.UpdatePartTimeEmployee(parttimeemployee);

                    _unitOfWork.Commit();

                    response = request.CreateResponse(HttpStatusCode.OK);
                }

                return response;
            }));
        }
Example #2
0
 public static void UpdatePartTimeEmployee(this PartTimeEmployee partTimeEmployee, PartTimeEmployeeViewModel partTimeEmployeeVM)
 {
     partTimeEmployee.PartTimeEmployeeRate = partTimeEmployeeVM.PartTimeEmployeeRate;
 }