public JsonResult BookVehicle([FromBody] FLBooking booking) { booking.DDate = booking.DDate.GetValueOrDefault().AddDays(1); booking.RetDate = booking.RetDate.GetValueOrDefault().AddDays(1); var token = _tokenValidator.Validate(HttpContext); if (!token.Success) { return(Json(new ReturnData <string> { Success = false, NotAuthenticated = true, Message = $"Unauthorized:-{token.Message}", })); } if (string.IsNullOrEmpty(booking.Purpose)) { return(Json(new ReturnData <string> { Success = false, Message = "Kindly, provide the purpose for booking", })); } var result = _unisolApiProxy.BookVehicle(booking).Result; var response = JsonConvert.DeserializeObject <ReturnData <dynamic> >(result); return(Json(response)); }
public JsonResult BookVehicle(FLBooking booking) { try { booking.Ref = GenerateRefNo(); booking.Status = "Pending"; booking.Personnel = booking.EmpNo; var procOnlineReq = new ProcOnlineReq { ReqRef = booking.Ref, DocType = "VEHICLE BOOKING", Rdate = DateTime.UtcNow.Date, Rtime = DateTime.UtcNow, Usercode = booking.EmpNo, Status = "Pending" }; var docId = _unitOfWork.Wfrouting.GetFirstOrDefault(r => r.Document.ToUpper() == procOnlineReq.DocType.ToUpper())?.Id.ToString(); if (string.IsNullOrEmpty(docId)) { return(Json(new ReturnData <string> { Success = false, Message = "Sorry, " + procOnlineReq.DocType.ToUpper() + " Not supported at the moment. Please contact the admin" })); } var user = _unitOfWork.HrpEmployee.GetFirstOrDefault(e => e.EmpNo.ToUpper().Equals(booking.EmpNo.ToUpper())); var workFlowStatus = utils.SaveToWorkFlowCenter(procOnlineReq, user, docId); if (!workFlowStatus.Success) { return(Json(workFlowStatus)); } booking.DDate = booking.DDate.GetValueOrDefault().Date; booking.RetDate = booking.RetDate.GetValueOrDefault().Date; booking.RDate = booking.RDate.GetValueOrDefault().Date; _unitOfWork.FLBooking.Add(booking); _unitOfWork.Save(); return(Json(new ReturnData <string> { Success = true, Message = "Applied Successfully" })); } catch (Exception e) { return(Json(new ReturnData <string> { Success = false, Message = "Opps, An error occured" })); } }
public Task <string> BookVehicle(FLBooking booking) { var response = Post("fleet/bookVehicle", booking); return(response); }