Пример #1
0
        public static OfferManageViewModel GetOfferManageViewModel(ApplicationDbContext db, Guid organisationId)
        {
            OfferManageViewModel model = new OfferManageViewModel()
            {
                OfferManageViewOffersCreated  = CreateActiveOffersCreatedByOrganisation(db, organisationId),
                OfferManageViewOffersReceived = CreateActiveOffersReceivedByOrganisation(db, organisationId)
            };

            //these flags are set to true if any single entry in the list has an editable quantity (ie. the user can enter a value).
            //If these flags are false then we use these to remove the uneccesary footer parts to the table that allows submission and reset of offers
            model.EditableEntriesCreated  = model.OfferManageViewOffersCreated.Any(x => x.EditableQuantity);
            model.EditableEntriesReceived = model.OfferManageViewOffersReceived.Any(x => x.EditableQuantity);

            return(model);
        }
        public ActionResult Offers(OfferManageViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request.Form["saveofferbutton"] != null)
                {
                    //Update offers
                    OfferHelpers.UpdateOffers(db, model.OfferManageViewOffersCreated, User);
                }

                if (Request.Form["savecounterofferbutton"] != null)
                {
                    //Update counter offers
                    OfferHelpers.UpdateCounterOffers(db, model.OfferManageViewOffersReceived, User);
                }

                return(RedirectToAction("Offers", "ManageInfo"));
            }

            return(View(model));
        }
        public ActionResult Offers()
        {
            OfferManageViewModel model = OfferViewHelpers.GetOfferManageViewModel(db, AppUserHelpers.GetOrganisationIdFromUser(db, User));

            return(View(model));
        }