Ejemplo n.º 1
0
        /// <summary>
        /// This is called by the BizRunner’s GetOriginal or ResetDto methods.
        /// It sets up the presentation layer properties
        /// </summary>
        /// <param name="repository">The repository to allow access to the database</param>
        /// <param name="status">The BizActionStatus so you can register errors</param>
        protected override void SetupSecondaryData(object repository, IStatusGenericHandler status)
        {
            if (OrderId == 0)
            {
                throw new InvalidOperationException("You must set the OrderId before you call SetupSecondaryData");
            }
            if (UserId == null)
            {
                throw new InvalidOperationException("You must set the UserId before you call SetupSecondaryData");
            }

            var order = ((NonEfRepo)repository).GetOrder(OrderId);

            if (order == null)
            {
                status.AddError("Sorry, I could not find the order you asked for.");
                HasErrors = true;
                //Log possible hacking
                return;
            }

            DateOrderedUtc       = order.DateOrderedUtc;
            OriginalDeliveryDate = order.ExpectedDeliveryDate;
            NewDeliveryDate      = OriginalDeliveryDate < DateTime.Today
                ? DateTime.Today
                : OriginalDeliveryDate;
            //BookTitles = order.LineItems.Select(x => x.ChosenBook.Title).ToList();
            PossibleDeliveryDates = new SelectList(FormPossibleDeliveryDates(DateTime.Today));
            var selected = PossibleDeliveryDates.FirstOrDefault(x => x.Text == NewDeliveryDate.ToString("d"));

            if (selected != null)
            {
                selected.Selected = true;
            }
        }
 protected override void SetupSecondaryData(DbContext db, IStatusGenericHandler status)
 {
     SetupSecondaryDataCalled = true;
     if (RaiseErrorInSetupSecondaryData)
     {
         status.AddError("Error in SetupSecondaryData");
     }
 }
 protected override void SetupSecondaryData(object repository, IStatusGenericHandler status)
 {
     SetupSecondaryDataCalled = true;
     if (RaiseErrorInSetupSecondaryData)
     {
         status.AddError("Error in SetupSecondaryData");
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Use this to setup any extra data needed when showing the dto to the user for input, e.g. supporting dropdownlists
 /// This is called a) when a dto is created by GetDto , b) when ResetDto is called and c) when the call to the business logic fails
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="status">You can raise an error, which will stop the biz logic from running</param>
 protected internal virtual void SetupSecondaryData(object repository, IStatusGenericHandler status)
 {
 }
 /// <summary>
 /// Use this to setup any extra data needed when showing the dto to the user for input, e.g. supporting dropdownlists
 /// This is called a) when a dto is created by GetDto , b) when ResetDto is called and c) when the call to the business logic fails
 /// </summary>
 /// <param name="db"></param>
 /// <param name="status">You can raise an error, which will stop the biz logic from running</param>
 protected internal virtual void SetupSecondaryData(DbContext db, IStatusGenericHandler status)
 {
 }