示例#1
0
        public async Task <HttpResponseMessage> Update(HttpRequestMessage request, RequestViewModel requestViewModel)
        {
            return(await CreateHttpResponse(request, () =>
            {
                var dbRequest = _requestService.GetById(requestViewModel.ID);
                //Check Old Day Breack
                _requestService.checkDayBreak(dbRequest);
                dbRequest.EditRequest(requestViewModel);
                //Check Request Day Off
                var model = _requestService.GetAllRequest(dbRequest);
                if (model == 0)
                {
                    if (_requestService.checkUnitEntitleday(dbRequest))
                    {
                        if (_requestService.CheckUpdateRequest(dbRequest))
                        {
                            _requestService.UpdateRequest(dbRequest);
                            return request.CreateResponse(HttpStatusCode.OK, "OK");
                        }
                        else
                        {
                            return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_CREATE_REQUEST_NOT_MSG);
                        }
                    }
                    else
                    {
                        return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_ENTITLEDAY);
                    }
                }
                if (model == 1)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME);
                }
                if (model == 2)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_MORNING);
                }
                if (model == 3)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_AFTERNOON);
                }
                if (model == 4)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_LATECOMING);
                }
                if (model == 5)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_EARLYLEAVING);
                }
                if (model == 6)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME);
                }
                if (model == 7)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_MORNING);
                }
                if (model == 8)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_MORNING_LATECOMING);
                }
                if (model == 9)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME);
                }
                if (model == 10)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_AFTERNOONLEAVE);
                }
                if (model == 11)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_AFTERNOONLEAVE_EARLYLEAVING);
                }
                if (model == 12)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME);
                }
                if (model == 13)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_MORNING_LATECOMING);
                }
                if (model == 14)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_LATECOMING_EARLYLEAVING);
                }
                if (model == 15)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME);
                }
                if (model == 16)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_EARLYLEAVING_AFTERNOONLEAVE);
                }
                if (model == 17)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_EARLYLEAVING);
                }


                var response = request.CreateResponse(HttpStatusCode.OK, "Xong");

                return response;
            }));
        }