Beispiel #1
0
        public ActionResult DesignIt(DesignOrderBm bm)
        {
            if (this.ModelState.IsValid)
            {
                this.service.AddFigures(bm);
                return(this.View(this.GetDesignOrderVm(bm.Id)));
            }

            return(this.View(this.GetDesignOrderVm(bm.Id)));
        }
Beispiel #2
0
        public void AddFigures(DesignOrderBm bm)
        {
            var order = this.orders
                        .All()
                        .FirstOrDefault(o => o.Id == bm.Id);

            if (order.Appearance.CookiesCount > order.Figures.Count)
            {
                order.Figures.Add(new Figure()
                {
                    Name = bm.FiguresName
                });

                this.orders.Update(order);
                this.orders.SaveChanges();
            }//todo write message can not add figure or do change of other
        }
        public void DesignPost_ShouldAddFigureAndReturnThisView()
        {
            var model = new DesignOrderBm()
            {
                Id          = 1,
                FiguresName = "Пеперуда"
            };

            this._controller.WithCallTo(order => order.DesignIt(model))
            .ShouldRenderDefaultView()
            .WithModel <DesignOrderVm>(m => m.Id = 1);

            var orderEntity = this._repository.Set.FirstOrDefault(o => o.Id == model.Id);

            if (orderEntity != null)
            {
                Assert.AreEqual(orderEntity.Figures.Count, 1);
            }
        }