public HttpResponseMessage FindRent([FromBody] GetRentParam param) { //kamus Rent rent = null; rent dbRent; HttpStatusCode status = HttpStatusCode.OK; HttpResponseMessage response; string message = null; Business.Infrastructure.FilterInfo filters; //algoritma filters = new Business.Infrastructure.FilterInfo { Field = "code", Operator = "eq", Value = param.RentCode }; dbRent = RepoRent.Find(filters); if (dbRent != null) { rent = new Rent(dbRent); } else { message = "Kode Booking tidak ditemukan"; status = HttpStatusCode.BadRequest; } response = Request.CreateResponse(status, rent); if (message != null) { response.Content.Headers.Add("ResponseMessage", message); } return(response); }
public HttpResponseMessage Submit([FromBody] GetRentParam param) { //kamus HttpResponseMessage response; HttpStatusCode status = HttpStatusCode.OK; Business.Infrastructure.FilterInfo filters; rent rent; api_rent apiRent; ApiRentStatus apiStatus; string message = null; //algoritma filters = new Business.Infrastructure.FilterInfo { Field = "code", Operator = "eq", Value = param.RentCode }; rent = RepoRent.Find(filters); if (rent == null) { status = HttpStatusCode.BadRequest; message = WebServiceMessage.OrderNotFoundAlert; } else { filters = new Business.Infrastructure.FilterInfo { Field = "id_rent", Operator = "eq", Value = rent.id.ToString() }; apiRent = RepoApiRent.Find(filters); if (apiRent == null) { status = HttpStatusCode.BadRequest; message = WebServiceMessage.OrderNotFoundAlert; } else { apiStatus = (ApiRentStatus)Enum.Parse(typeof(ApiRentStatus), apiRent.status); if (apiRent.cancellation_status != null) { status = HttpStatusCode.BadRequest; message = WebServiceMessage.CancelAlert; } else { apiRent.cancellation_status = ApiRentCancellationStatus.CANCEL.ToString(); RepoApiRent.Save(apiRent); } } } response = Request.CreateResponse(status); if (message != null) { response.Headers.Add("ResponseMessage", message); } return(response); }