public async Task Only_Requesting_Unit_member_Can_Approve() { var order = new Order { Id = 1, ItemId = 1, LendingUnitId = 2, RequestingMemberId = 1, RequestingUnitId = 3, Status = OrderStatusId.New }; var member = new Member(2, 1, Permission.CanConfirmOrder); var orderingService = new Mock <IOrderingService>(); orderingService.Setup(a => a.GetOrder(1)).ReturnsAsync(order); orderingService.Setup(a => a.GetMemberById(2)).ReturnsAsync(member); orderingService.Setup(a => a.UpdateOrder(It.IsAny <Order>())) .ReturnsAsync(new Core.Ordering.Dto.GatewayResponses.BaseGatewayResponse(true)); var handler = new AprroveHanlder(orderingService.Object); var request = new ApproveRequest(1, 2); var response = await handler.Handle(request); Assert.IsFalse(response.Success); }
public override Task <ApproveResponse> Approve(ApproveRequest request, ServerCallContext context) { return(Task.FromResult(new ApproveResponse { Proposal = repo.Approve(request.Id) })); }
public override Task <ApproveReply> Approve(ApproveRequest request, ServerCallContext context) { var orderId = request.OrderId; _logger.LogInformation($"approving order {orderId}"); if (_orders.ContainsKey(orderId)) { var order = _orders[orderId]; order.State = OrderState.SUBMITED; } return(Task.FromResult(new ApproveReply { Success = true, Message = $"approved order {orderId}" })); }
public HttpResponseMessage Cancel(ApproveRequest approveRequest) { HttpResponseMessage response = null; try { var result = travelRequestService.Cancel(approveRequest.TravelRequestId, approveRequest.TravelRequestBadgeNumber, approveRequest.Comments); response = Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { LogMessage.Log("api/travelrequest/cancel:" + ex.Message); response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Cancel was not sucessfull. Please try again."); } return(response); }
public HttpResponseMessage Approve(ApproveRequest approveRequest) { HttpResponseMessage response = null; try { var result = reimbursementService.Approve(approveRequest.ApproverBadgeNumber, approveRequest.TravelRequestId, approveRequest.Comments); response = Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { LogMessage.Log("api/reimburse/approve :" + ex.Message); response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Approve was not sucessfull. Please try again."); } return(response); }
public HttpResponseMessage Reject(ApproveRequest approveRequest) { HttpResponseMessage response = null; try { var result = travelRequestService.Reject(approveRequest); response = Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { LogMessage.Log("api/travelrequest/reject :" + ex.Message); response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Reject was not sucessfull. Please try again."); } return(response); }
public bool Reject(ApproveRequest approveRequest) { var result = travelRequestRepo.Reject(approveRequest); return(result); }
public HttpResponseMessage approveRequest(approveRequest data) { COM.DBHelper sqlhelper = new COM.DBHelper(); GlobalVarible.Clear(); List <string> strvalidationResult = new List <string>(); try { string token = _LOGINUSERID.ToString(); string reqdata = ENCDESC.Decrypt(data.data, token, data.userid); MDL.ApproveRequest model = new ApproveRequest(); model = new JavaScriptSerializer().Deserialize <MDL.ApproveRequest>(reqdata); strvalidationResult = ValidateApproveRequest(model); if (strvalidationResult.Count() == 0) { if (checkpassword(model.loginpassword)) { Guid wrid = new Guid(model.wr_id); Guid userid = Guid.Parse(User.Identity.GetUserId()); string[,] param = { { "WR_ID", wrid.ToString() }, { "UPPERID", userid.ToString() } }; COM.DBHelper.SQLReturnValue M = sqlhelper.ExecuteProcWithMessageKMT("WALLET_APPROVED", param, true); if (M.ValueFromSQL == 1) { // get detail user device token using (BAL.WalletRequest objUDT = new BAL.WalletRequest()) { ENT.WalletRequest request = objUDT.GetRequestById(Guid.Parse(model.wr_id)); if (request != null) { string message = "Your account is credited with with " + request.wr_amount.ToString(); FCMNOTIFICATION.SendPushNotification(request.udt_devicetoken, message, request.wr_userid, 1); } } GlobalVarible.AddMessage(M.MessageFromSQL); } else { throw new Exception(string.Join("<br />", M.MessageFromSQL)); } } else { throw new Exception(string.Join("<br />", "Invalid Password !")); } } else { throw new Exception(string.Join("<br />", strvalidationResult)); } return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } catch (Exception ex) { GlobalVarible.AddError(ex.Message); ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult })); } }