Ejemplo n.º 1
0
        public static void GetTripAsync(GetTripQueryBuilder url, TripDelegate callback)
        {
            try
            {
                if (url == null) throw new Exception("Cannot work with null-objects");
                if (String.IsNullOrEmpty(url.Url)) throw new Exception("Url cannot be empty");

                var client = new WebClient();

                client.DownloadStringCompleted += (s, e) =>
                {
                    if (e.Error != null) throw new Exception("", e.Error);
                    if (e.Result == null) return;

                    var collection = JsonHelper.Deserialize<Trip>(e.Result);

                    callback(collection);
                };

                client.DownloadStringAsync(new Uri(url.Url));
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,EmployeeNumber,EmployeeName,EmployeMobile,JopName,TripBookingId")] TripDelegate tripDelegate)
        {
            if (id != tripDelegate.Id)
            {
                Response.StatusCode = 404;
                return(View("TripDelegatesNotFound"));
            }

            if (ModelState.IsValid)
            {
                if (empDelegateExist(id, tripDelegate.EmployeeNumber, tripDelegate.TripBookingId))
                {
                    TempData["message"]       = " رقم الموظف (" + tripDelegate.EmployeeNumber + ") موجود مسبقا في نفس الرحلة !! ";
                    ViewData["TripBookingId"] = tripDelegate.TripBookingId;
                    return(View(tripDelegate));
                }
                _context.Update(tripDelegate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { bokingId = tripDelegate.TripBookingId }));
            }
            ViewData["TripBookingId"] = tripDelegate.TripBookingId;
            return(View(tripDelegate));
        }