// GET: Admin public ActionResult Index() { var adminService = new AdminService.AdminServiceSoapClient(); var packageService = new PackageWebService.PackageWSClient(); var result = adminService.GetAllPackages(); var packages = new List <PackageModel>(); var packagesV = new List <PackageModelV>(); if (!result.Equals("no elements")) { packages = JsonConvert.DeserializeObject <List <PackageModel> >(result); foreach (var p in packages) { var pack = new PackageModelV { id = p.id, description = p.description, destinationCity = p.destinationCity, name = p.name, senderCity = p.senderCity, tracking = p.tracking, Sender = packageService.getClientNameById(p.idSender), Receiver = packageService.getClientNameById(p.idReceiver) }; packagesV.Add(pack); } if (TempData["Mess"] != null) { ViewBag.Mess = TempData["Mess"].ToString(); TempData.Remove("Mess"); } } else { ViewBag.Mess = "There isn't any package"; } return(View(packagesV)); }
// GET: Client public ActionResult Index(string searchString) { var userId = Convert.ToInt32(Session["userId"]); var packageService = new PackageWebService.PackageWSClient(); var packages = new List <PackageModel>(); var packagesV = new List <PackageModelV>(); if (string.IsNullOrEmpty(searchString)) { var result = packageService.getClientPackage(userId); if (!result.Equals("no element")) { packages = JsonConvert.DeserializeObject <List <PackageModel> >(result); foreach (var p in packages) { var pack = new PackageModelV { id = p.id, description = p.description, destinationCity = p.destinationCity, name = p.name, senderCity = p.senderCity, tracking = p.tracking, Sender = packageService.getClientNameById(p.idSender), Receiver = packageService.getClientNameById(p.idReceiver) }; packagesV.Add(pack); } } else { ViewBag.Mess = "You don't have any package!"; } } else { var result = packageService.search(searchString, userId); if (!result.Equals("no element")) { packages = JsonConvert.DeserializeObject <List <PackageModel> >(result); foreach (var p in packages) { var pack = new PackageModelV { id = p.id, description = p.description, destinationCity = p.destinationCity, name = p.name, senderCity = p.senderCity, tracking = p.tracking, Sender = packageService.getClientNameById(p.idSender), Receiver = packageService.getClientNameById(p.idReceiver) }; packagesV.Add(pack); } } else { ViewBag.Mess = "You don't have any package!"; } } return(View(packagesV)); }