public ActionResult CreatePackage(Models.PackageModel package) { try { if (!ModelState.IsValid) { return(View("CreatePackage", package)); } string username = Request.Cookies.Get("login").Values["feketePorzeczka"]; var userPoints = _proxy.GetAllUsers().SingleOrDefault(x => x.Username == username).Points; if (int.Parse(package.Price) <= userPoints) { var packageModelToInsert = new SenderServiceReference1.PackageModel { ToAddress = package.ToAddress, FromAddress = package.FromAddress, Weight = package.Weight, Width = package.Width, Height = package.Width, ReceiverFirstName = package.ReceiverFirstName, ReceiverLastName = package.ReceiverLastName, ReceiverPhoneNumber = package.ReceiverPhoneNumber }; var deliveryModelToInsert = new SenderServiceReference1.DeliveryModel { Distance = double.Parse(package.Distance.Split(' ')[0]), Price = int.Parse(package.Price) }; var result = _proxy.AddPackage(packageModelToInsert, username, deliveryModelToInsert); if (result == 1) { return(RedirectToAction("Index")); } else { return(RedirectToAction("CreatePackage", package)); } } else { ModelState.AddModelError("Price", "You do not have enough points!"); return(View("CreatePackage", package)); } } catch { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }