public void AddOffer(CreateOffer createOffer)
        {
            var offer = AutoMapper.Mapper.Map <Offer>(createOffer);

            _applicationContext.Offers.Add(offer);
            _applicationContext.SaveChanges();
        }
예제 #2
0
        public async Task <ActionResult> CreateOffer(OfferDto offer)
        {
            await _posAuthLoader.AssertResourceAccessAsync(User, offer.PointOfSaleId, IsAuthorizedUserPolicy.Instance);

            var cmd = new CreateOffer(Guid.NewGuid(), offer.PointOfSaleId, offer.ProductId, offer.RecommendedPrice, offer.StockItemId, offer.ValidSince, offer.ValidUntil);

            return(await SendAndHandleIdentifierResultCommand(cmd, nameof(GetOffer)));
        }
        /// <summary>
        /// Creates a new offer, and adds it to the catalog. After creation, status information can be retrieved to review if the offer is valid and published to the shop.
        /// </summary>
        /// <param name="offer">The offer to create</param>
        /// <returns></returns>
        public async Task <StatusResponse> CreateNewOffer(CreateOffer offer)
        {
            using (var content = BolApiHelper.BuildContentFromObject(offer))
            {
                var response = await Post("/offers", content).ConfigureAwait(false);

                return(await BolApiHelper.GetContentFromResponse <StatusResponse>(response).ConfigureAwait(false));
            }
        }
예제 #4
0
 public ActionResult CreateOffer(CreateOffer createOffer)
 {
     if (ModelState.IsValid)
     {
         _offerService.AddOffer(createOffer);
         return(View("ConfirmOffer", createOffer));
     }
     return(View(createOffer));
 }
예제 #5
0
        //Loads 2 aggregate roots, but commit only one
        public async Task Handle(CreateOffer message)
        {
            var product = await _session.Get <Product>(message.ProductId);

            var merchant = await _session.Get <Merchant>(message.MerchantId);

            product.CreateOffer(message.Id, message.MerchantId, message.Stock, message.Price, merchant.Activated, merchant.Name, message.SKU);

            await _session.Commit();
        }
예제 #6
0
        public async Task CreateOffer()
        {
            var bolApiCaller = new BolApiCaller(testClientId, testClientSecret, true);
            var condition    = new Condition(ConditionName.GOOD);
            var bundlePrices = new List <BundlePrice>
            {
                new BundlePrice(1, 5.55m)
            };
            var pricing     = new PricingContainer(bundlePrices);
            var stock       = new Stock(5, false);
            var fulfilment  = new SmallFulfilment(FulFilmentMethod.FBB);
            var createOffer = new CreateOffer("9789492493804", condition, pricing, stock, fulfilment)
            {
                Reference = "Test-Api"
            };
            var result = await bolApiCaller.Offers.CreateNewOffer(createOffer);

            Assert.IsTrue(result.Description == "Create an offer with ean 9789492493804.");
        }
예제 #7
0
        public ActionResult CreateOffer(CreateOffer t)
        {
            int doc_number = 0;
            var tu         = db.Users.Where(a => a.UserName == User.Identity.Name).First().tModerator;

            if (tu.Count != 0)
            {
                FbConnectionStringBuilder fc = new FbConnectionStringBuilder();
                fc.Database = tu.First().tModerator_database;
                fc.UserID   = tu.First().tModerator_userId;
                fc.Password = tu.First().tModerator_password;
                fc.Role     = "R_ADMIN";
                fc.Pooling  = false;
                fc.Charset  = "win1251";
                using (FbConnection fb = new FbConnection(fc.ConnectionString))
                {
                    try
                    {
                        fb.Open();
                        using (FbTransaction ft = fb.BeginTransaction())
                        {
                            using (FbCommand fcon = new FbCommand("select G.NUM " +
                                                                  "from GET_DC_DOCUMENT_NUMBER(85) G", fb, ft))
                            {
                                using (FbDataReader fr = fcon.ExecuteReader())
                                {
                                    while (fr.Read())
                                    {
                                        doc_number = (int)fr[0];
                                    }
                                    fr.Dispose();
                                }
                                fcon.Dispose();
                            }

                            var _com = "execute procedure IUD_BUGS('I', null, @IS_ERROR, @LOCATION, @ID_RELEASE_PROJECTS, @ID_RELEASE_PROJECTS_EXEC," +
                                       " null, null, @ID_SUBSYSTEM," +
                                       "@ID_BRANCH, null, 85, 1, (select list_id from sel_filter_budg(2)),@DOC_NUMBER, 'NOW'," +
                                       "null, @comment, null, @DETAIL_COMMENT, 1, @ID_PROJECTS, null,null) ";
                            using (FbCommand fcon = new FbCommand(_com, fb, ft))
                            {
                                switch (t._iserror)
                                {
                                case true:
                                    fcon.Parameters.AddWithValue("@IS_ERROR", '1');
                                    break;

                                default:
                                    fcon.Parameters.AddWithValue("@IS_ERROR", '0');
                                    break;
                                }
                                fcon.Parameters.AddWithValue("@LOCATION", t._location);
                                fcon.Parameters.AddWithValue("@ID_RELEASE_PROJECTS", t.id_release_projects);
                                fcon.Parameters.AddWithValue("@ID_RELEASE_PROJECTS_EXEC", t.id_release_projects_exec);
                                fcon.Parameters.AddWithValue("@ID_SUBSYSTEM", t.id_subsystem);
                                fcon.Parameters.AddWithValue("@ID_BRANCH", t.id_branch);
                                if (t._message.Id != 0)
                                {
                                    var val = this.Url.RequestContext.HttpContext.Request.Url.Scheme;
                                    fcon.Parameters.AddWithValue("@comment", t._message.tForumThemes.tForumThemes_name);
                                    fcon.Parameters.AddWithValue("@DETAIL_COMMENT",
                                                                 "<em><a href ='" +
                                                                 Url.Action("Index", "ForumMessages", new { id = t._message.tForumThemes.Id, id_list = t._message.tForumThemes.tForumList.Id }, val) +
                                                                 "'> " +
                                                                 Url.Action("Index", "ForumMessages", new { id = t._message.tForumThemes.Id, id_list = t._message.tForumThemes.tForumList.Id }, val) +
                                                                 "</a></em>" +
                                                                 "<p>" + t._message.tForumMessages_messages + "</p>");
                                }
                                else
                                {
                                    var val = this.Url.RequestContext.HttpContext.Request.Url.Scheme;

                                    fcon.Parameters.AddWithValue("@comment", t._themes.tForumThemes_name);
                                    fcon.Parameters.AddWithValue("@DETAIL_COMMENT",
                                                                 "<em><a href ='" +
                                                                 Url.Action("Index", "ForumMessages", new { id = t._themes.Id, id_list = t._themes.tForumList.Id }, val) +
                                                                 "'> " +
                                                                 Url.Action("Index", "ForumMessages", new { id = t._themes.Id, id_list = t._themes.tForumList.Id }, val) +
                                                                 "</a></em>" +
                                                                 "<p>" + t._themes.tForumThemes_desc + "</p>");
                                }

                                fcon.Parameters.AddWithValue("@ID_PROJECTS", t.id_projects);

                                fcon.Parameters.AddWithValue("@DOC_NUMBER", doc_number);
                                try
                                {
                                    fcon.ExecuteNonQuery();
                                    ft.Commit();
                                }
                                catch (FbException ex1)
                                {
                                    ModelState.AddModelError("", ex1.Message);
                                    ft.Rollback();
                                }
                                finally
                                {
                                    fcon.Dispose();
                                }
                            }
                            ft.Dispose();
                        }
                    }
                    catch (FbException ex)
                    {
                        ModelState.AddModelError("", ex.Message);
                        return(View(t));
                    }
                    finally
                    {
                        fb.Close();
                    }
                    fb.Dispose();
                }
            }
            else
            {
                return(RedirectToAction("Settings"));
            }
            return(RedirectToAction("Index", "ForumList"));
        }