예제 #1
0
 public IActionResult EditDate(EditDateViewModel model)
 {
     try                      //Error handling
     {
         EditDateCall(model); //Calls Edit Date to API
     }
     catch
     {
         return(RedirectToAction("APIError"));
     }
     _toastNotification.AddInfoToastMessage("The event date has been edited!");
     return(RedirectToAction("TimelineView", new { id = GetTimelineID(model.TimelineEventId) })); //returns to the Index!
 }
        public async Task<ActionResult> Index(Guid id)
        {
            var dateHistories = await mediator.SendAsync(new GetMovementDateHistory(id));
            var notificationId = await mediator.SendAsync(new GetNotificationIdByMovementId(id));

            var model = new EditDateViewModel
            {
                DateEditHistory = dateHistories
                    .OrderBy(dh => dh.DateChanged)
                    .Select(dh => dh.PreviousDate)
                    .ToList(),
                NotificationId = notificationId
            };

            return View(model);
        }
예제 #3
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            IDictionary <string, string> parameters = this.NavigationContext.QueryString;

            if (parameters.ContainsKey("DateId"))
            {
                DateId = parameters["DateId"];
            }


            if (e.NavigationMode != NavigationMode.Back)
            {
                SlideTransition transition = new SlideTransition();
                transition.Mode = SlideTransitionMode.SlideRightFadeIn;

                PhoneApplicationPage page  = (PhoneApplicationPage)((PhoneApplicationFrame)Application.Current.RootVisual).Content;
                ITransition          trans = transition.GetTransition(page);

                trans.Completed += delegate
                {
                    trans.Stop();

                    if (e.NavigationMode == NavigationMode.New)
                    {
                        editDateViewModel = new EditDateViewModel(Int32.Parse(DateId), this);
                        this.DataContext  = editDateViewModel;

                        DoubleLoopingDataSource doubleLoopingDataSource = new DoubleLoopingDataSource()
                        {
                            MinValue = 0, MaxValue = 5, SelectedItem = editDateViewModel.EditDate.Rating
                        };
                        doubleLoopingDataSource.SelectionChanged += new EventHandler <SelectionChangedEventArgs>(LoopingSelector_SelectionChanged);

                        IntLoopingDataSource intLoopingDataSource = new IntLoopingDataSource()
                        {
                            MinValue = 0, MaxValue = 10, SelectedItem = editDateViewModel.EditDate.Rating
                        };
                        intLoopingDataSource.SelectionChanged += new EventHandler <SelectionChangedEventArgs>(LoopingSelector_SelectionChanged);
                        this.selector.DataSource = doubleLoopingDataSource;
                    }
                };
                trans.Begin();
            }
        }
예제 #4
0
        public async Task <ActionResult> Index(Guid id)
        {
            var dateHistories = await mediator.SendAsync(new GetMovementDateHistory(id));

            var notificationId = await mediator.SendAsync(new GetNotificationIdByMovementId(id));

            var model = new EditDateViewModel
            {
                DateEditHistory = dateHistories
                                  .OrderBy(dh => dh.DateChanged)
                                  .Select(dh => dh.PreviousDate)
                                  .ToList(),
                NotificationId = notificationId
            };

            return(View(model));
        }
        public async Task<ActionResult> Index(Guid id, EditDateViewModel model)
        {
            if (!ModelState.IsValid || !model.AsDateTime().HasValue)
            {
                return View(model);
            }

            var proposedDate = await mediator.SendAsync(new IsProposedUpdatedMovementDateValid(id, model.AsDateTime().Value));

            if (proposedDate.IsOutsideConsentPeriod)
            {
                ModelState.AddModelError("Day",
                    "The actual date of shipment cannot be outside of the consent validity period. Please enter a different date.");
            }

            if (proposedDate.IsOutOfRange)
            {
                ModelState.AddModelError("Day",
                    "The actual date of shipment cannot be more than 30 calendar days in the future. Please enter a different date.");
            }

            if (proposedDate.IsOutOfRangeOfOriginalDate)
            {
                ModelState.AddModelError("Day",
                    "The actual date of shipment cannot be more than 10 working days after the original date. Please enter a different date.");
            }

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var notificationId = await mediator.SendAsync(new GetNotificationIdByMovementId(id));

            var workingDaysUntilShipment = await mediator.SendAsync(new GetWorkingDaysUntil(notificationId, model.AsDateTime().GetValueOrDefault()));

            if (workingDaysUntilShipment < 4)
            {
                TempData[ShipmentDateKey] = model.AsDateTime();
                return RedirectToAction("ThreeWorkingDaysWarning", "EditDate");
            }

            await mediator.SendAsync(new UpdateMovementDate(id, model.AsDateTime().Value));

            return RedirectToAction("Index", "Options", new { area = "NotificationApplication", id = notificationId });
        }
예제 #6
0
        /// <summary>
        /// Calls API to edit date
        /// </summary>
        /// <param name="model">EditDateViewModel model containing the data to update</param>
        private void EditDateCall(EditDateViewModel model)
        {
            model.EventDateTime.ToString();
            CultureInfo ukCulture = new CultureInfo("en-GB");                                                         //Handles international dates

            try                                                                                                       //Error handling for date parsing
            {
                model.EventDateTime = DateTime.Parse(model.EventDateTime, ukCulture.DateTimeFormat).Ticks.ToString(); //Parse Date
            }
            catch
            {
                throw new System.ArgumentException("Parameter cannot be null", "original");
            }

            var request = new RestRequest("TimelineEvent/EditEventDateTime");

            if (!PutRequest(request, model).Equals("OK")) //Error Handling
            {
                throw new System.ArgumentException("Parameter cannot be null", "original");
            }
        }
예제 #7
0
        public async Task <ActionResult> Index(Guid id, EditDateViewModel model)
        {
            if (!ModelState.IsValid || !model.AsDateTime().HasValue)
            {
                return(View(model));
            }

            var proposedDate = await mediator.SendAsync(new IsProposedUpdatedMovementDateValid(id, model.AsDateTime().Value));

            var remainingShipmentsData = await mediator.SendAsync(new GetRemainingShipments(model.NotificationId, model.AsDateTime()));

            if (proposedDate.IsOutRangeDateInPast)
            {
                ModelState.AddModelError("ActualDateofShipment",
                                         "The actual date of shipment cannot be in the past. Please enter a different date.");
            }

            if (proposedDate.IsOutsideConsentPeriod)
            {
                ModelState.AddModelError("ActualDateofShipment",
                                         "The actual date of shipment cannot be outside of the consent validity period. Please enter a different date.");
            }

            if (proposedDate.IsOutOfRange)
            {
                ModelState.AddModelError("ActualDateofShipment",
                                         "The actual date of shipment cannot be more than 30 calendar days in the future. Please enter a different date.");
            }

            if (proposedDate.IsOutOfRangeOfOriginalDate)
            {
                ModelState.AddModelError("ActualDateofShipment",
                                         "The actual date of shipment cannot be more than 10 working days after the original date. Please enter a different date.");
            }

            if (remainingShipmentsData.ActiveLoadsRemainingByDate < 1)
            {
                ModelState.AddModelError("ActualDateofShipment",
                                         string.Format("You already have {0} prenotifications for {1} and you are only permitted to prenotify {2} shipments. {3} shipment will exceed your limit on that date.",
                                                       remainingShipmentsData.ActiveLoadsPermitted - remainingShipmentsData.ActiveLoadsRemainingByDate,
                                                       model.AsDateTime().Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
                                                       remainingShipmentsData.ActiveLoadsPermitted,
                                                       1));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var notificationId = await mediator.SendAsync(new GetNotificationIdByMovementId(id));

            var workingDaysUntilShipment = await mediator.SendAsync(new GetWorkingDaysUntil(notificationId, model.AsDateTime().GetValueOrDefault()));

            if (workingDaysUntilShipment < 4)
            {
                TempData[ShipmentDateKey] = model.AsDateTime();
                return(RedirectToAction("ThreeWorkingDaysWarning", "EditDate"));
            }

            await mediator.SendAsync(new UpdateMovementDate(id, model.AsDateTime().Value));

            return(RedirectToAction("Index", "Options", new { area = "NotificationApplication", id = notificationId }));
        }
예제 #8
0
        public PartialViewResult EditDate(string Id, string Date)
        {
            EditDateViewModel model = new EditDateViewModel(Id, Date);

            return(PartialView("_EditDate", model));
        }