コード例 #1
0
        public static OrderViewModel GetOfferViewModel(ApplicationDbContext db, HttpRequestBase request, Guid orderId, string breadcrumb, string callingActionDisplayName, bool displayOnly, string type, bool?recalled, string controllerValue, string actionValue, IPrincipal user)
        {
            AppUser currentUser = AppUserHelpers.GetAppUser(db, user);

            Dictionary <int, string> breadcrumbDictionary = new Dictionary <int, string>();

            breadcrumbDictionary.Add(0, breadcrumb);

            if (!recalled.HasValue || recalled.Value != true)
            {
                GeneralHelpers.GetCallingDetailsFromRequest(request, controllerValue, actionValue, out controllerValue, out actionValue);
            }

            Order order = OrderHelpers.GetOrder(db, orderId);

            string       itemDescription = "";
            ItemTypeEnum itemType        = ItemTypeEnum.Canned;
            string       uoM             = "";

            if (order.ListingType == ListingTypeEnum.Available)
            {
                AvailableListing listing = AvailableListingHelpers.GetAvailableListing(db, order.ListingId.Value);
                itemDescription = listing.ItemDescription;
                itemType        = listing.ItemType;
                uoM             = listing.UoM;
            }
            else
            {
                RequiredListing listing = RequiredListingHelpers.GetRequiredListing(db, order.ListingId.Value);
                itemDescription = listing.ItemDescription;
                itemType        = listing.ItemType;
                uoM             = listing.UoM;
            }

            OrderViewModel model = new OrderViewModel()
            {
                DisplayOnly          = displayOnly,
                Breadcrumb           = breadcrumb,
                BreadcrumbDictionary = breadcrumbDictionary,
                Type                          = type,
                OrderId                       = order.OrderId,
                ListingType                   = order.ListingType,
                ItemDescription               = itemDescription,
                ItemType                      = itemType,
                UoM                           = uoM,
                OrderQuanity                  = order.OrderQuanity,
                OrderInStatus                 = order.OrderInStatus,
                OrderOutStatus                = order.OrderOutStatus,
                OrderCreationDateTime         = order.OrderCreationDateTime,
                OrderDistributionDateTime     = order.OrderDistributionDateTime,
                OrderDistributedBy            = AppUserHelpers.GetAppUserName(db, order.OrderDistributedBy),
                OrderDeliveredDateTime        = order.OrderDeliveredDateTime,
                OrderDeliveredBy              = AppUserHelpers.GetAppUserName(db, order.OrderDeliveredBy),
                OrderCollectedDateTime        = order.OrderCollectedDateTime,
                OrderCollectedBy              = AppUserHelpers.GetAppUserName(db, order.OrderCollectedBy),
                OrderReceivedDateTime         = order.OrderReceivedDateTime,
                OrderReceivedBy               = AppUserHelpers.GetAppUserName(db, order.OrderReceivedBy),
                OrderInClosedDateTime         = order.OrderInClosedDateTime,
                OrderInClosedBy               = AppUserHelpers.GetAppUserName(db, order.OrderInClosedBy),
                OrderOutClosedDateTime        = order.OrderOutClosedDateTime,
                OrderOutClosedBy              = AppUserHelpers.GetAppUserName(db, order.OrderOutClosedBy),
                OrderOriginatorAppUser        = AppUserHelpers.GetAppUserName(db, order.OrderOriginatorAppUserId),
                OrderOriginatorOrganisation   = OrganisationHelpers.GetOrganisationName(db, order.OrderOriginatorOrganisationId),
                OrderOriginatorDateTime       = order.OrderOriginatorDateTime,
                OfferId                       = order.OfferId,
                OfferOriginatorAppUser        = AppUserHelpers.GetAppUserName(db, order.OfferOriginatorAppUserId),
                OfferOriginatorOrganisation   = OrganisationHelpers.GetOrganisationName(db, order.OfferOriginatorOrganisationId),
                ListingId                     = order.ListingId,
                ListingOriginatorAppUser      = AppUserHelpers.GetAppUserName(db, order.ListingOriginatorAppUserId),
                ListingOriginatorOrganisation = OrganisationHelpers.GetOrganisationName(db, order.ListingOriginatorOrganisationId),
                CallingAction                 = actionValue,
                CallingActionDisplayName      = callingActionDisplayName,
                CallingController             = controllerValue,
                BreadcrumbTrail               = breadcrumbDictionary
            };

            return(model);
        }
コード例 #2
0
        public static OfferViewModel GetOfferViewModel(ApplicationDbContext db, HttpRequestBase request, Guid offerId, string breadcrumb, string callingActionDisplayName, bool displayOnly, string type, bool?recalled, string controllerValue, string actionValue, IPrincipal user)
        {
            AppUser currentUser = AppUserHelpers.GetAppUser(db, user);
            Dictionary <int, string> breadcrumbDictionary = new Dictionary <int, string>();

            breadcrumbDictionary.Add(0, breadcrumb);

            if (!recalled.HasValue || recalled.Value != true)
            {
                GeneralHelpers.GetCallingDetailsFromRequest(request, controllerValue, actionValue, out controllerValue, out actionValue);
            }

            Offer offer = OfferHelpers.GetOffer(db, offerId);

            OfferViewModel model = new OfferViewModel()
            {
                DisplayOnly          = displayOnly,
                Breadcrumb           = breadcrumb,
                BreadcrumbDictionary = breadcrumbDictionary,
                Type                                 = type,
                OfferId                              = offer.OfferId,
                ListingId                            = offer.ListingId,
                ListingType                          = offer.ListingType,
                OfferStatus                          = offer.OfferStatus,
                ItemDescription                      = offer.ItemDescription,
                QuantityOutstanding                  = OfferViewHelpers.GetListingQuantityForListingIdListingType(db, offer.ListingId, offer.ListingType),
                CurrentOfferQuantity                 = offer.CurrentOfferQuantity,
                PreviousOfferQuantity                = offer.PreviousOfferQuantity,
                CounterOfferQuantity                 = offer.CounterOfferQuantity,
                PreviousCounterOfferQuantity         = offer.PreviousCounterOfferQuantity,
                OfferOriginatorAppUser               = AppUserHelpers.GetAppUserName(db, offer.OfferOriginatorAppUserId),
                OfferOriginatorOrganisation          = OrganisationHelpers.GetOrganisationName(db, offer.OfferOriginatorOrganisationId),
                OfferOriginatorDateTime              = offer.OfferOriginatorDateTime,
                YourOrganisationId                   = currentUser.OrganisationId,
                OfferOriginatorOrganisationId        = offer.OfferOriginatorOrganisationId,
                RejectedBy                           = AppUserHelpers.GetAppUserName(db, offer.RejectedBy),
                RejectedOn                           = offer.RejectedOn,
                LastOfferOriginatorAppUser           = AppUserHelpers.GetAppUserName(db, offer.LastOfferOriginatorAppUserId),
                LastOfferOriginatorDateTime          = offer.LastOfferOriginatorDateTime,
                ListingOriginatorAppUser             = AppUserHelpers.GetAppUserName(db, offer.ListingOriginatorAppUserId),
                ListingOriginatorOrganisation        = OrganisationHelpers.GetOrganisationName(db, offer.ListingOriginatorOrganisationId),
                ListingOriginatorDateTime            = offer.ListingOriginatorDateTime,
                CounterOfferOriginatorAppUser        = AppUserHelpers.GetAppUserName(db, offer.CounterOfferOriginatorAppUserId),
                CounterOfferOriginatorOrganisation   = OrganisationHelpers.GetOrganisationName(db, offer.CounterOfferOriginatorOrganisationId),
                CounterOfferOriginatorDateTime       = offer.CounterOfferOriginatorDateTime,
                CounterOfferOriginatorOrganisationId = offer.CounterOfferOriginatorOrganisationId,
                LastCounterOfferOriginatorAppUser    = AppUserHelpers.GetAppUserName(db, offer.LastCounterOfferOriginatorAppUserId),
                LastCounterOfferOriginatorDateTime   = offer.LastCounterOfferOriginatorDateTime,
                OrderOriginatorAppUser               = AppUserHelpers.GetAppUserName(db, offer.OrderOriginatorAppUserId),
                OrderOriginatorOrganisation          = OrganisationHelpers.GetOrganisationName(db, offer.OrderOriginatorOrganisationId),
                OrderOriginatorDateTime              = offer.OrderOriginatorDateTime,
                CallingAction                        = actionValue,
                CallingActionDisplayName             = callingActionDisplayName,
                CallingController                    = controllerValue,
                BreadcrumbTrail                      = breadcrumbDictionary
            };

            if (displayOnly)
            {
                model.EditableQuantity = false;
            }
            else
            {
                if (type == "created")
                {
                    model.EditableQuantity = offer.CurrentOfferQuantity == 0;
                }
                else if (type == "received")
                {
                    model.EditableQuantity = offer.CurrentOfferQuantity > 0;
                }
            }

            return(model);
        }