public async Task <ActionResult> EnableConfirmed(long id) { var url = $"api/GoodsOut/DeliveryRequest/enable/{id}/{_updatedBy}/"; var response = await HttpClientHelper.ApiCall(url, Method.PUT); if (response.IsSuccessful) { TempData["Message"] = "Delivery Request successfully enabled!"; //Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestController).Name) + "||Delete||DeliveryRequest ID::{0}||API Response::{1}", id, response)); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestController).Name) + "||Enable||DeliveryRequest ID::{0}||API Response::{1}", id, response)); //return RedirectToAction("Index"); } return(RedirectToAction("Index", "DeliveryRequest")); }
public async Task <ActionResult> DeleteConfirmed(long id) { var url = $"api/haulier/delete/{id}/{_updatedBy}/"; var response = await HttpClientHelper.ApiCall(url, Method.DELETE); if (response.IsSuccessful) { TempData["Message"] = "Haulier successfully deleted!"; TempData["MessageAlert"] = "success"; //Log.Error(string.Format(Type.GetType(typeof(HaulierController).Name) + "||Delete||Haulier ID::{0}||API Response::{1}", id, response)); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(HaulierController).Name) + "||Delete||Haulier ID::{0}||API Response::{1}", id, response)); //return RedirectToAction("Index"); } return(RedirectToAction("Index", "Haulier")); }
public async Task <ActionResult> Details(int id, string GoodsReceivedNumber, string StatusCode) { var expectedReceiptLine = new ExpectedReceiptViewModel.ExpectedReceiptLine(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var obj = new ExpectedReceiptViewModel.ExpectedReceiptLine(); var url = "api/GoodsIn/ExpectedReceipt/Lines/GetById/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj.Id = data.Id; obj.ExpectedReceiptId = data.ExpectedReceiptId; obj.Line = data.Line; obj.Batch = data.Batch; obj.Quantity = data.Quantity; obj.BrandName = data.Brand == null ? "" : data.Brand.Name; obj.BrandCode = data.BrandCode; obj.ExpiryDate = data.ExpiryDate; obj.ItemCode = data.ItemCode; obj.ItemDescription = data.ItemDescription; obj.ProductCode = data.Product == null ? "" : data.Product.Description; obj.UomDescription = data.Uom == null ? "" : data.Uom.Description; } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ExpectedReceiptLinesController).Name) + "||Details||Expected Receipt Lines ID::{0}||API Response::{1}", expectedReceiptLine.Id, response)); return(RedirectToAction("Index", "ExpectedReceiptLines", new { id = expectedReceiptLine.ExpectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode })); } ViewBag.GoodsReceivedNo = GoodsReceivedNumber; ViewBag.StatCode = StatusCode; return(PartialView(obj)); }
public async Task <ActionResult> Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var obj = new DeliveryRequestLineViewModel(); var url = "api/GoodsOut/DeliveryRequest/Line/getbyid/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj = new DeliveryRequestLineViewModel { Id = data.Id, CustomerId = data.CustomerId, DeliveryRequestId = data.DeliveryRequestId, PickTypeId = data.PickTypeId, PickType = data.PickType ?? "", ProductId = data.ProductId, ProductDescription = data.Product ?? "", BrandId = data.BrandId, Brand = data.Brand ?? "", ItemId = data.ItemId, ItemDescription = data.Item ?? "", UomId = data.UomId, UomDescription = data.Uom ?? "", Quantity = data.Quantity ?? 0, Memo = data.Memo ?? "", SpecialInstructions = data.SpecialInstructions ?? "", IsActive = data.IsActive, CreatedBy = data.CreatedBy, DateCreated = data.DateCreated }; } return(PartialView(obj)); }
public async Task <ActionResult> Create([Bind(Include = "Id,ProductId,ItemId,WarehouseId,LocationId,TotalQtyStock")] StockAssignViewModel stockAssignViewModel) { var url = "api/stockasign/add"; var response = await HttpClientHelper.ApiCall(url, Method.POST, stockAssignViewModel); if (response.IsSuccessful) { TempData["Message"] = "Successfully Created"; return(RedirectToAction("Index")); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestViewModel).Name) + "||Create||StockAssign ID::{0}||API Response::{1}", stockAssignViewModel.Id, response)); return(RedirectToAction("Index")); } //ViewBag.ItemId = new SelectList(db.ItemViewModels, "Id", "Description", stockAssignViewModel.ItemId); //ViewBag.LocationId = new SelectList(db.LocationViewModels, "Id", "Description", stockAssignViewModel.LocationId); //ViewBag.ProductId = new SelectList(db.ProductViewModels, "Id", "Description", stockAssignViewModel.ProductId); //ViewBag.WarehouseId = new SelectList(db.WarehouseViewModels, "Id", "WarehouseCode", stockAssignViewModel.WarehouseId); }
public async Task <JsonResult> HaulierList(string term) { var list = new List <HaulierViewModel>(); var url = $"api/Haulier/GetList/{true}/{_customerId}"; //term = ""; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; list = JsonConvert.DeserializeObject <List <HaulierViewModel> >(result); return(Json(list.Where(x => x.Name?.ToLower().Contains(term.ToLower()) ?? false) .Select(x => new { id = x.Id, text = x.Name }).ToList())); } return(null); }
public async Task <ActionResult> DeleteConfirmed(DeliveryRequestLineViewModel obj, long id) { //var deliveryRequestId = Request.Form["DeliveryRequestId"]; //FormCollection["DeliveryRequestId"]; var url = $"api/GoodsOut/DeliveryRequest/Line/delete/{id}/{_updatedBy}/"; var response = await HttpClientHelper.ApiCall(url, Method.DELETE); if (response.IsSuccessful) { TempData["Message"] = "Successfully Deleted"; //Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestLineController).Name) + "||Delete||DeliveryRequestLine ID::{0}||API Response::{1}", id, response)); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestLineController).Name) + "||Delete||DeliveryRequestLine ID::{0}||API Response::{1}", id, response)); //return RedirectToAction("Index", new { id = DeliveryRequestId }); } return(RedirectToAction("Index", new { id = obj.DeliveryRequestId })); }
public async Task <ActionResult> Edit([Bind(Include = "Id, CustomerId, DeliveryRequestId, ProductId, BrandId," + "ItemId, PickTypeId, UomId, Quantity, SpecialInstructions, Memo, IsActive, CreatedBy, DateCreated")] DeliveryRequestLineViewModel obj) { obj.UpdatedBy = CookieHelper.EmailAddress; var url = "api/GoodsOut/DeliveryRequest/Line/update"; var response = await HttpClientHelper.ApiCall(url, Method.PUT, obj); if (response.IsSuccessful) { TempData["Message"] = "Successfully Updated"; //Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestLineController).Name) + "||Update||DeliveryRequestLine ID::{0}||API Response::{1}", obj.Id, response)); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestLineController).Name) + "||Update||DeliveryRequestLine ID::{0}||API Response::{1}", obj.Id, response)); //return PartialView(obj); } return(RedirectToAction("Index", new { id = obj.DeliveryRequestId })); }
public async Task <ActionResult> Edit([Bind(Include = "Id,ItemId,ProductId,WarehouseId,DeliveryRequestId")] DispatchViewModel dispatchViewModel) { var url = "api/dispatch/update"; var response = await HttpClientHelper.ApiCall(url, Method.PUT, dispatchViewModel); if (response.IsSuccessful) { TempData["Message"] = "Successfully Updated"; return(RedirectToAction("Index")); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(DispatchViewModel).Name) + "||Edit||Dispatch ID::{0}||API Response::{1}", dispatchViewModel.Id, response)); return(RedirectToAction("Index")); } //ViewBag.DeliveryRequestId = new SelectList(db.DeliveryRequestViewModels, "Id", "Requestor", dispatchViewModel.DeliveryRequestId); //ViewBag.ItemId = new SelectList(db.ItemViewModels, "Id", "Description", dispatchViewModel.ItemId); //ViewBag.ProductId = new SelectList(db.ProductViewModels, "Id", "Description", dispatchViewModel.ProductId); //ViewBag.WarehouseId = new SelectList(db.WarehouseViewModels, "Id", "WarehouseCode", dispatchViewModel.WarehouseId);0- }
public async Task <JsonResult> GetDefaultBrandJson(int productId) { var expectedReceiptLine = new ExpectedReceiptViewModel.ExpectedReceiptLine(); if (productId == null) { return(Json(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } var obj = new ExpectedReceiptViewModel.ExpectedReceiptLine(); var url = "api/Brand/GetByProductId/" + productId; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj.Id = data.Id; obj.ExpectedReceiptId = data.ExpectedReceiptId; obj.Line = data.Line; obj.Batch = data.Batch; obj.Quantity = data.Quantity; obj.BrandName = data.BrandName; obj.BrandCode = data.BrandCode; obj.ExpiryDate = data.ExpiryDate; obj.ItemCode = data.ItemCode; obj.ItemDescription = data.ItemDescription; obj.ProductCode = data.Product == null ? "" : data.Product.Description; obj.UomDescription = data.Uom == null ? "" : data.Uom.Description; } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ExpectedReceiptLinesController).Name) + "||Details||Expected Receipt Lines ID::{0}||API Response::{1}", expectedReceiptLine.Id, response)); return(Json("Index", "ExpectedReceiptLines")); } return(Json(obj)); }
public async Task <ActionResult> Delete(int id, int expectedReceiptId, ExpectedReceiptViewModel.ExpectedReceiptLine expectedReceiptLine) { var url = $"api/GoodsIn/ExpectedReceipt/Lines/Delete/{id}/{_updatedBy}/"; var response = await HttpClientHelper.ApiCall(url, Method.DELETE); if (response.IsSuccessful) { TempData["Message"] = "Line successfully deleted!"; TempData["MessageAlert"] = "success"; return(RedirectToAction("Index", "ExpectedReceiptLines", new { id = expectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode })); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ExpectedReceiptLinesController).Name) + "||Delete||Expected Receipt Lines ID::{0}||API Response::{1}", id, response)); return(RedirectToAction("Index", "ExpectedReceiptLines", new { id = expectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode })); } //using (var client = new HttpClient()) //{ // var url = new Uri(ConfigHelper.BaseUrl) + "api/GoodsIn/ExpectedReceipt/Lines/Delete"; // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", CookieHelper.Token); // HttpResponseMessage responseMessage = await client.DeleteAsync(url + "/" + id); // if (responseMessage.IsSuccessStatusCode) // { // TempData["Message"] = "Line Successfully Deleted"; // TempData["MessageAlert"] = "success"; // return RedirectToAction("Index", "ExpectedReceiptLines", new { id = expectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode }); // } // else // { // Error("An error has occurred"); // Log.Error(string.Format(Type.GetType(typeof().Name) + "||Delete||Expected Receipt Lines ID::{0}||API Response::{1}", id, responseMessage)); // return RedirectToAction("Index", "ExpectedReceiptLines", new { id = eExpectedReceiptLinesControllerxpectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode }); // } //} }
// GET: PickType/Details/5 public async Task <ActionResult> Details(int?id) { var obj = new PickTypeViewModels(); var url = "api/PickType/GetById/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj = new PickTypeViewModels { Id = data.Id, CustomerId = data.CustomerId, Code = data.Code, Description = data.Description, IsActive = data.IsActive, }; } return(PartialView(obj)); }
public async Task <ActionResult> Edit([Bind(Include = "Id, CustomerId, GoodsReceivedNumber, ReferenceNumber, ExpectedReceiptDate, WarehouseId, VendorId, WarehouseCode, Address, Supplier, HaulierId," + "HaulierName, HaulierCode, Comments, Received, ReceivedDate, DateCreated, StatusId, StatusCode, ReceivedBy, Planned, UpdatedBy, IsActive, DateCreated, CreatedBy, DateUpdated, UpdatedBy, Received")] ExpectedReceiptViewModel.ExpectedReceipt expectedReceipt) { expectedReceipt.CustomerId = 1; expectedReceipt.UpdatedBy = CookieHelper.EmailAddress; var url = "api/GoodsIn/ExpectedReceipt/Update"; var response = await HttpClientHelper.ApiCall(url, Method.PUT, expectedReceipt); if (response.IsSuccessful) { TempData["Message"] = expectedReceipt.GoodsReceivedNumber + " is successfully updated!"; TempData["MessageAlert"] = "success"; return(RedirectToAction("Index", "Receipt", expectedReceipt.StatusCode)); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ReceiptController).Name) + "||Update||Receipt ID::{0}||API Response::{1}", expectedReceipt.Id, response)); return(RedirectToAction("Index", "Receipt")); } return(PartialView(expectedReceipt)); }
public async Task <JsonResult> VendorIdList(string term) { var list = new List <VendorViewModel>(); var url = $"api/Vendor/GetList/{true}/{_customerId}"; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var obj = JsonConvert.DeserializeObject <List <VendorViewModel> >(result); list = obj; var warehouse = list.Where(x => (x.VendorName?.ToLower().Contains(term.ToLower()) ?? false)) .Select(x => new { id = x.Id, text = x.VendorName }).ToList(); return(Json(warehouse)); } return(null); }
public async Task <ActionResult> Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var obj = new DeliveryRequestLineItemViewModel(); var url = "api/GoodsOut/CustomerDespatch/Line/Item/getbyid/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj.Id = data.Id; obj.DeliveryRequestLineId = data.DeliveryRequestLineId; obj.ItemId = data.ItemId; obj.ItemDescription = data.Item.Description; } return(PartialView(obj)); }
public async Task <ActionResult> Edit([Bind(Include = "Id, CustomerId, Code, Description, IsActive, CreatedBy, DateCreated")] PickTypeViewModels obj) { obj.UpdatedBy = CookieHelper.EmailAddress; var url = "api/PickType/Update"; var response = await HttpClientHelper.ApiCall(url, Method.PUT, obj); if (response.IsSuccessful) { TempData["Message"] = obj.Description + " successfully updated!"; TempData["MessageAlert"] = "success"; //return RedirectToAction("Index", "Item"); } //else if(responseMessage.StatusCode == HttpStatusCode.BadRequest) else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(PickTypeController).Name) + "||Edit||Pick Type ID::{0}||API Response::{1}", obj.Id, response)); //return RedirectToAction("Index", "Item"); } return(RedirectToAction("Index", "PickType")); }
public async Task <JsonResult> PickTypeList(string term) { var list = new List <PickTypeViewModels>(); var url = $"api/PickType/GetList/{true}/{_customerId}"; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var customerId = int.Parse(CookieHelper.CustomerId); var result = response.Content; list = JsonConvert.DeserializeObject <List <PickTypeViewModels> >(result); return(Json(list.Where(x => (x.Description?.ToLower().Contains(term.ToLower()) ?? false) && x.CustomerId == customerId ) .Select(x => new { id = x.Id, text = x.Description }).ToList())); } return(Json(null)); }
public async Task <ActionResult> Details(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var obj = new ExpectedReceiptViewModel.ExpectedReceipt(); var url = "api/GoodsIn/ExpectedReceipt/GetById/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj.Id = data.Id; obj.ExpectedReceiptDate = data.ExpectedReceiptDate; obj.AutoReferenceNumber = data.AutoReferenceNumber; obj.GoodsReceivedNumber = data.GoodsReceivedNumber; obj.ReferenceNumber = data.ReferenceNumber; obj.Received = data.Received; obj.Comments = data.Comments; obj.StatusId = data.StatusId; obj.Address = data.Address; obj.WarehouseCode = data.Warehouse.Description; obj.ReceivedBy = data.ReceivedBy; obj.ReceivedDate = data.ReceivedDate; obj.Supplier = data.Supplier; obj.HaulierName = data.Haulier == null ? "" : data.Haulier.Name; obj.HaulierCode = data.Haulier == null ? "" : data.Haulier.HaulierCode; obj.StatusCode = data.Status == null ? "" : data.Status.Name; obj.Planned = data.Planned; obj.IsActive = data.IsActive; } return(PartialView(obj)); }
public async Task <ActionResult> Create([Bind(Include = "CustomerId, GoodsReceivedNumber, AutoReferenceNumber, ReferenceNumber, ExpectedReceiptDate, WarehouseId, WarehouseCode," + " Address, Supplier, VendorId, HaulierId, HaulierName, HaulierCode, Comments, Received, ReceivedDate, DateCreated, StatusCode, StatusId, ReceivedBy, Planned, IsActive, CreatedBy")] ExpectedReceiptViewModel.ExpectedReceipt expectedReceipt) { expectedReceipt.IsProcessing = false; expectedReceipt.Planned = true; expectedReceipt.IsActive = true; expectedReceipt.StatusId = ForReceivingStatus; expectedReceipt.CreatedBy = CookieHelper.EmailAddress; var url = "api/GoodsIn/ExpectedReceipt/add"; var response = await HttpClientHelper.ApiCall(url, Method.POST, expectedReceipt); if (response.StatusCode == HttpStatusCode.Forbidden) { TempData["Message"] = expectedReceipt.ReferenceNumber + " is already exist! Please check your Reference Number and try again."; TempData["MessageAlert"] = "warning"; return(RedirectToAction("Index", new { StatusId = expectedReceipt.StatusId })); } if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); TempData["Message"] = expectedReceipt.ReferenceNumber + " successfully created!"; TempData["MessageAlert"] = "success"; return(RedirectToAction("Index", "ExpectedReceipt", new { StatusId = expectedReceipt.StatusId })); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ExpectedReceiptController).Name) + "||Create||Expected Receipt ID::{0}||API Response::{1}", expectedReceipt.Id, response)); return(RedirectToAction("Index", "ExpectedReceipt", new { StatusId = expectedReceipt.StatusId })); } }
public async Task <ActionResult> Edit([Bind(Include = "Id, DeliveryRequestCode, RequestType, RequestedDate, RequiredDeliveryDate," + "HaulierId, ServiceCode, CustomerRef, RequiredDate, EarliestDate, LatestDate, SalesOrderRef, WarehouseId," + "IsFullfilled, CustomerClientId, CustomerId, StatusId, IsActive, CreatedBy, DateCreated, IsProcessing")] DeliveryRequestViewModel obj) { obj.UpdatedBy = CookieHelper.EmailAddress; var url = "api/GoodsOut/DeliveryRequest/update"; var response = await HttpClientHelper.ApiCall(url, Method.PUT, obj); if (response.IsSuccessful) { TempData["Message"] = "Delivery Request successfully updated"; //Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestController).Name) + "||Update||DeliveryRequest ID::{0}||API Response::{1}", deliveryRequestViewModel.Id, response)); //return RedirectToAction("Index", "DeliveryRequest"); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(DeliveryRequestController).Name) + "||Update||DeliveryRequest ID::{0}||API Response::{1}", obj.Id, response)); //return PartialView(deliveryRequestViewModel); } return(RedirectToAction("Index", "DeliveryRequest")); }
public async Task <JsonResult> TransactionTypesList(string term) { var list = new List <TransactionTypesViewModel>(); var url = $"api/TransactionTypes/GetList/{true}/{_customerId}"; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; var obj = JsonConvert.DeserializeObject <List <TransactionTypesViewModel> >(result); list = obj; var transTypes = list.Where(x => x.TransType?.ToLower().Contains(term.ToLower()) ?? false) .Select(x => new { id = x.Id, text = x.TransType }).ToList(); return(Json(transTypes)); } return(null); }
public async Task <JsonResult> Upload() { try { foreach (string file in Request.Files) { HttpPostedFileBase fileContent = Request.Files[file]; Stream stream = fileContent.InputStream; string fileName = Path.GetFileName(file); byte[] fileBytes = new byte[fileContent.ContentLength]; var data = stream.Read(fileBytes, 0, Convert.ToInt32(fileContent.ContentLength)); using (var xls = new ExcelPackage(fileContent.InputStream)) { var xlsSheets = xls.Workbook.Worksheets; var workSheet = xlsSheets.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; var rowItr = 2; var products = new List <ProductViewModel>(); var brands = new List <BrandViewModel>(); var whses = new List <WarehouseViewModel>(); var locs = new List <LocationViewModel>(); var items = new List <ItemViewModel>(); var method = Method.POST; var url = "api/Product/GetSelectList/"; var response = await HttpClientHelper.ApiCall(url, Method.GET); //var awaitResponse = response.GetAwaiter().GetResult(); if (response.IsSuccessful) { //var products = workSheet.Cells[rowItr, 3, noOfRow, 3].Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct(); products = JsonConvert.DeserializeObject <List <dynamic> >(response.Content) .Select(x => new ProductViewModel { Id = x.Id, ProductCode = x.ProductCode, Description = x.Description }).ToList(); } url = "api/Brand/GetSelectList/"; response = await HttpClientHelper.ApiCall(url, Method.GET); //awaitResponse = response.GetAwaiter().GetResult(); if (response.IsSuccessful) { //var brands = workSheet.Cells[rowItr, 4, noOfRow, 4].Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct(); brands = JsonConvert.DeserializeObject <List <dynamic> >(response.Content) .Select(x => new BrandViewModel { Id = x.Id, Code = x.Code, Name = x.Name }).ToList(); } url = "api/Warehouse/GetSelectList/"; response = await HttpClientHelper.ApiCall(url, Method.GET); //awaitResponse = response.GetAwaiter().GetResult(); if (response.IsSuccessful) { //var warehouses = workSheet.Cells[rowItr, 5, noOfRow, 5].Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct(); whses = JsonConvert.DeserializeObject <List <dynamic> >(response.Content) .Select(x => new WarehouseViewModel { Id = x.Id, WarehouseCode = x.WarehouseCode, Description = x.Description }).ToList(); } url = "api/Location/GetAll/"; response = await HttpClientHelper.ApiCall(url, Method.GET); //awaitResponse = response.GetAwaiter().GetResult(); if (response.IsSuccessful) { //var locations = workSheet.Cells[rowItr, 6, noOfRow, 6].Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct(); locs = JsonConvert.DeserializeObject <List <dynamic> >(response.Content) .Select(x => new LocationViewModel { Id = x.Id, LocationCode = x.LocationCode, Description = x.Description }).ToList(); } url = "api/Item/GetAll/"; response = await HttpClientHelper.ApiCall(url, Method.GET); //awaitResponse = response.GetAwaiter().GetResult(); if (response.IsSuccessful) { //var locations = workSheet.Cells[rowItr, 6, noOfRow, 6].Where(x => x.Value != null).Select(x => x.Value.ToString()).Distinct(); items = JsonConvert.DeserializeObject <List <dynamic> >(response.Content) .Select(x => new ItemViewModel { Id = x.Id, ItemCode = x.ItemCode, Description = x.Description }).ToList(); } for (rowItr = 2; rowItr <= noOfRow; rowItr++) { var itemCode = workSheet.Cells[rowItr, 1].Value?.ToString() ?? ""; if (itemCode != null) { var itemDesc = workSheet.Cells[rowItr, 2].Value?.ToString() ?? ""; var productDesc = workSheet.Cells[rowItr, 3].Value?.ToString() ?? ""; var brandDesc = workSheet.Cells[rowItr, 4].Value?.ToString() ?? ""; var whseDesc = workSheet.Cells[rowItr, 5].Value?.ToString() ?? ""; var locDesc = workSheet.Cells[rowItr, 6].Value?.ToString() ?? ""; var quantity = long.Parse(workSheet.Cells[rowItr, 7].Value?.ToString() ?? "0"); var batchCode = workSheet.Cells[rowItr, 8].Value?.ToString() ?? ""; var product = products.FirstOrDefault(x => string.Equals(x.ProductCode, productDesc, StringComparison.OrdinalIgnoreCase) || string.Equals(x.Description, productDesc, StringComparison.OrdinalIgnoreCase)); var brand = brands.FirstOrDefault(x => string.Equals(x.Code, brandDesc, StringComparison.OrdinalIgnoreCase) || string.Equals(x.Name, brandDesc, StringComparison.OrdinalIgnoreCase)); var whse = whses.FirstOrDefault(x => string.Equals(x.WarehouseCode, whseDesc, StringComparison.OrdinalIgnoreCase) || string.Equals(x.Description, whseDesc, StringComparison.OrdinalIgnoreCase)); var loc = locs.FirstOrDefault(x => string.Equals(x.LocationCode, locDesc, StringComparison.OrdinalIgnoreCase) || string.Equals(x.Description, locDesc, StringComparison.OrdinalIgnoreCase)); var item = new ItemViewModel { ItemCode = itemCode, Description = itemDesc, ProductId = product?.Id ?? null, ProductCode = product?.ProductCode ?? null, BrandId = brand?.Id ?? null, BrandCode = brand?.Code ?? null, WarehouseId = whse?.Id ?? null, WarehouseCode = whse?.WarehouseCode ?? null, LocationId = loc?.Id ?? null, LocationCode = loc?.LocationCode ?? null, CustomerId = long.Parse(CookieHelper.CustomerId), Quantity = quantity, BatchCode = batchCode, IsActive = true }; var apiItem = items.FirstOrDefault(x => string.Equals(x.ItemCode, itemCode, StringComparison.OrdinalIgnoreCase)); if (apiItem == null) { method = Method.POST; url = "api/Item/Add"; } else { method = Method.PUT; url = "api/Item/Update"; } response = await HttpClientHelper.ApiCall(url, method, item); //var responseMessageAwait = responseMessage.GetAwaiter().GetResult(); if (!response.IsSuccessful) { return(Json(new { status = "failed", message = "An error has occurred. Not all items are uploaded." })); } else { Log.Info(string.Format(Type.GetType(typeof(ItemController).Name) + "||Upload||Item ID::{0}||API Response::{1}", item.Id, response)); } } } return(Json(new { status = "success", message = "File Uploading Successful." })); } } } catch (Exception ex) { Log.Error(string.Format(Type.GetType(typeof(ItemController).Name) + "||Upload||Item||Exception:{0}", ex.Message)); return(Json(new { status = "failed", message = "An error has occurred." })); } return(null); }
public async Task <ActionResult> Create([Bind(Include = "ExpectedReceiptId, CustomerId ProductId, UomId, CustomerId, Line, ProductCode, ItemDescription, ItemCode, ItemId, Batch, ExpiryDate," + " Quantity,UomDescription, BrandId, BrandName, IsChecked, ReferenceNumber, GoodsReceivedNumber, StatusCode, IsActive, CreatedBy, DateCreated, IsItemExist, StatusId")] ExpectedReceiptLine expectedReceiptLine) { expectedReceiptLine.IsChecked = false; expectedReceiptLine.IsActive = true; expectedReceiptLine.CreatedBy = CookieHelper.EmailAddress; expectedReceiptLine.IsItemExist = true; var url = "api/GoodsIn/ExpectedReceipt/Lines/Add"; var response = await HttpClientHelper.ApiCall(url, Method.POST, expectedReceiptLine); if (response.StatusCode == HttpStatusCode.Forbidden) { TempData["Message"] = expectedReceiptLine.ItemCode + " is already exist! Please check and try again."; TempData["MessageAlert"] = "warning"; return(RedirectToAction("Index")); } if (response.IsSuccessful) { TempData["Message"] = expectedReceiptLine.ItemDescription + " successfully created!"; TempData["MessageAlert"] = "success"; return(RedirectToAction("Index", new { id = expectedReceiptLine.ExpectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode, IsActive = expectedReceiptLine.IsActive })); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ExpectedReceiptLinesController).Name) + "||Create||Expected Receipt Lines ID::{0}||API Response::{1}", expectedReceiptLine.Id, response)); return(RedirectToAction("Index", new { id = expectedReceiptLine.ExpectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode, IsActive = expectedReceiptLine.IsActive })); } return(PartialView(expectedReceiptLine)); //using (var client = new HttpClient()) //{ // var url = new Uri(ConfigHelper.BaseUrl) + "api/GoodsIn/ExpectedReceipt/Lines/Add"; // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", CookieHelper.Token); // HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, expectedReceiptLine); // if (responseMessage.StatusCode == HttpStatusCode.Forbidden) // { // TempData["Message"] = expectedReceiptLine.ItemCode + " is already exist! Please check and try again."; // TempData["MessageAlert"] = "warning"; // return RedirectToAction("Index"); // } // if (responseMessage.IsSuccessStatusCode) // { // TempData["Message"] = "Line Successfully Created"; // TempData["MessageAlert"] = "success"; // return RedirectToAction("Index", "ExpectedReceiptLines", new { id = expectedReceiptLine.ExpectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber , StatusCode = expectedReceiptLine.StatusCode }); // } // else // { // Error("An error has occurred"); // Log.Error(string.Format(Type.GetType(typeof(ExpectedReceiptLinesController).Name) + "||Create||Expected Receipt Lines ID::{0}||API Response::{1}", expectedReceiptLine.Id, responseMessage)); // return RedirectToAction("Index", "ExpectedReceiptLines", new { id = expectedReceiptLine.ExpectedReceiptId, GoodsReceivedNumber = expectedReceiptLine.GoodsReceivedNumber, StatusCode = expectedReceiptLine.StatusCode }); // } //} //return PartialView(expectedReceiptLine); }
public async Task <JsonResult> Complete(int id) { var url = ""; if (id == null) { return(Json(new HttpStatusCodeResult(HttpStatusCode.BadRequest))); } var obj = new ExpectedReceiptViewModel.ExpectedReceipt(); url = "api/GoodsIn/ExpectedReceipt/GetById/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); obj.CustomerId = 1; if (response.IsSuccessful) { var result = response.Content; var data = JsonConvert.DeserializeObject <dynamic>(result); obj.Id = data.Id; obj.ExpectedReceiptDate = data.ExpectedReceiptDate; obj.GoodsReceivedNumber = data.GoodsReceivedNumber; obj.ReferenceNumber = data.ReferenceNumber; obj.Received = data.Received; obj.Comments = data.Comments; obj.Address = data.Address; obj.WarehouseDescription = data.Warehouse.Description; obj.WarehouseCode = data.Warehouse.WarehouseCode; obj.ReceivedBy = data.ReceivedBy; obj.ReceivedDate = data.ReceivedDate; obj.Supplier = data.Supplier; obj.StatusId = 7; obj.HaulierId = data.HaulierId; obj.HaulierName = data.Haulier == null ? "" : data.Haulier.Name; obj.HaulierCode = data.Haulier == null ? "" : data.Haulier.HaulierCode; obj.Planned = data.Planned; obj.IsActive = data.IsActive; obj.DateCreated = data.DateCreated; obj.CreatedBy = data.CreatedBy; obj.UpdatedBy = CookieHelper.EmailAddress; } var list = new List <ExpectedReceiptViewModel.ExpectedReceiptLine>(); var urlLine = "api/GoodsIn/ExpectedReceipt/Lines/GetList/" + id; var responseLine = await HttpClientHelper.ApiCall(urlLine, Method.GET); if (responseLine.Content == "[]") { TempData["Message"] = obj.GoodsReceivedNumber + " has no line item! Unable to mark it as COMPLETED!"; TempData["MessageAlert"] = "warning"; return(Json("Index", "Receipt")); } else { url = "api/GoodsIn/ExpectedReceipt/Update"; var responseMess = await HttpClientHelper.ApiCall(url, Method.PUT, obj); if (responseMess.IsSuccessful) { TempData["Message"] = obj.GoodsReceivedNumber + " is already COMPLETED!"; TempData["MessageAlert"] = "success"; return(Json("Index", "Receipt")); } else { Error("An error has occurred"); Log.Error(string.Format(Type.GetType(typeof(ReceiptController).Name) + "||Update||Expected Receipt ID::{0}||API Response::{1}", id, responseMess)); return(Json("Index", "Receipt")); } } }