//Nang Sandar: Create New Order Request public async Task <IActionResult> CreateRequest() { int userId = (int)HttpContext.Session.GetInt32("UserID"); string cartItemJson = HttpContext.Session.GetString("addedItemSession"); ItemRequest itemreq = new ItemRequest(); itemreq.UserID = userId; itemreq.ItemList = JsonConvert.DeserializeObject <List <AddToCartItem> >(cartItemJson); string jsonData = JsonConvert.SerializeObject(itemreq); Request req = new Request(); using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(jsonData), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync(api_url + "ItemList/CreateRequest", content)) { string apiResponse = await response.Content.ReadAsStringAsync(); req = JsonConvert.DeserializeObject <Request>(apiResponse); } } if (req != null) { HttpContext.Session.Remove("addedItemSession"); HttpContext.Session.Remove("countSession"); } NotificationController.NewRequest(userId); return(RedirectToAction("ViewCart")); }
public async Task <IActionResult> DisburseByRequest(int id, int userId, string collectionTime, List <int> fulfillQty) { int fromID = (int)HttpContext.Session.GetInt32("UserID"); int toID; using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(fulfillQty), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync(api_url + "disburse-by-request/" + id + "/" + userId + "/" + collectionTime + "/" + fulfillQty, content)) { string apiResponse = await response.Content.ReadAsStringAsync(); toID = JsonConvert.DeserializeObject <int>(apiResponse); } NotificationController.ReadyForCollection(fromID, toID); } return(RedirectToAction("ManageDisbursement")); }
public async Task <IActionResult> AddAdjustmentVoucher(string adjustType, int itemId, int adjustQty, string reason, int userId, string entryPoint) { int fromID = (int)HttpContext.Session.GetInt32("UserID"); List <User> toID = new List <User>(); using (var httpClient = new HttpClient()) { if (reason == null) { using (var response = await httpClient.GetAsync(api_url + "/addAdjustment/" + adjustType + "/" + itemId + "/" + adjustQty + "/" + userId)) { string apiResponse = await response.Content.ReadAsStringAsync(); toID = JsonConvert.DeserializeObject <List <User> >(apiResponse); } } else { using (var response = await httpClient.GetAsync(api_url + "/addAdjustment/" + adjustType + "/" + itemId + "/" + adjustQty + "/" + reason + "/" + userId)) { string apiResponse = await response.Content.ReadAsStringAsync(); toID = JsonConvert.DeserializeObject <List <User> >(apiResponse); } } } foreach (User u in toID) { NotificationController.AdjustmentVoucherForApproval(fromID, u.UserID); } if (entryPoint.Equals("inventory")) { return(RedirectToAction("InventoryList", "ItemList")); } return(RedirectToAction("RetrievalForm", "Disbursement")); }
public async Task <IActionResult> CompleteRetrieval(List <int> retrievedQty, int retrievalId, string collectionDate, int id) { int fromID = (int)HttpContext.Session.GetInt32("UserID"); List <User> toID = new List <User>(); using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(retrievedQty), Encoding.UTF8, "application/json"); using (var reponse = await httpClient.PostAsync(api_url_retrieval + "/allocate/" + retrievedQty + "/" + retrievalId + "/" + collectionDate + "/" + id, content)) { string apiResponse = await reponse.Content.ReadAsStringAsync(); toID = JsonConvert.DeserializeObject <List <User> >(apiResponse); } } foreach (User u in toID) { NotificationController.ReadyForCollection(fromID, u.UserID); } return(RedirectToAction("ManageDisbursement")); }