public void Execute(ViewModel model)
        {
            OrderTemplate orderItem = new OrderTemplate();

            foreach (var item in model.OrderList)
            {
                if (item.Id == model.Product.Id)
                {
                    if (item.Count > 1)
                    {
                        item.Count -= 1;
                        AddValidationMessage(model, "Ürün eksiltme işlemi başarıyla gerçekleşti. ", NotificationTypes.success);
                    }
                    else
                    {
                        orderItem = item;
                    }
                    break;
                }
            }

            if (orderItem?.Id == model.Product.Id)
            {
                model.OrderList.Remove(orderItem);
                AddValidationMessage(model, "Silme işlemi başarıyla gerçekleşti. ", NotificationTypes.success);
            }

            GetProductList(model);
            CalculateOrder(model);
        }
Exemplo n.º 2
0
        public async Task <string> CompilePrint <T>(T model)
        {
            var instance = new OrderTemplate(this._mySettingsConfig, new ViewRenderService());
            var template = (IPrintTemplate <T>)instance;

            return(await template.Compile(model));
        }
Exemplo n.º 3
0
        public ContentResult SaveOrderTemplate(OrderTemplate model)
        {
            if (model.ID == 0)
            {
                var op = new OrderTemplate {
                    Name = model.Name
                };
                op.Name       = model.Name;
                op.ContractId = model.ContractId;

                var id = dataLogic.CreateOrderTemplate(op);
                return(Content(JsonConvert.SerializeObject(new { ID = id })));
            }
            else
            {
                var legalId      = contractLogic.GetContract(model.ContractId.Value).LegalId;
                var contractorId = legalLogic.GetLegal(legalId).ContractorId.Value;

                // проверка прав участника
                if (!participantLogic.IsAllowedActionByContractor(38, legalLogic.GetLegal(contractorId).ContractorId.Value, CurrentUserId))
                {
                    return(Content(JsonConvert.SerializeObject(new { ActionId = 38, Message = "У вас недостаточно прав на выполнение этого действия." })));
                }

                var op = dataLogic.GetOrderTemplate(model.ID);
                op.Name       = model.Name;
                op.ContractId = model.ContractId;

                dataLogic.UpdateOrderTemplate(op);
                return(Content(JsonConvert.SerializeObject("")));
            }
        }
Exemplo n.º 4
0
        private void AddOrderItem(ORDER order, OrderTemplate item)
        {
            ORDER_ITEMS orderItem = new ORDER_ITEMS
            {
                OrderId              = order.Id,
                ProductId            = item.Id,
                ProductPrice         = Convert.ToDouble(item.Price),
                ProductDiscountPrice = Convert.ToDouble(item.DiscountPrice),
                DiscountValue        = Convert.ToDouble(item.Price) - Convert.ToDouble(item.DiscountPrice)
            };

            Repository.Context.ORDER_ITEMS.Add(orderItem);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="purchaseForm"></param>
        /// <returns></returns>
        public string AddPurchase(OrderTemplate purchaseForm)
        {
            SetDefaultHeaders();

            return(LibrettoDatabase.PurchaseIntegration.Insert(new Purchase
            {
                Quantity = purchaseForm.quantity,
                Total = purchaseForm.total,
                BookId = new Guid(purchaseForm.bookId),
                CustomerId = new Guid(purchaseForm.customerId),
                BookTitle = purchaseForm.bookTitle,
                CustomerName = purchaseForm.customerName
            }) == Response.Success ? "Ok" : "ERROR");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderForm"></param>
        /// <returns></returns>
        public string AddOrder(OrderTemplate orderForm)
        {
            SetDefaultHeaders();

            return(LibrettoDatabase.OrderIntegration.Insert(new Order
            {
                Quantity = orderForm.quantity,
                Total = orderForm.total,
                BookId = new Guid(orderForm.bookId),
                CustomerId = new Guid(orderForm.customerId),
                BookTitle = orderForm.bookTitle,
                CustomerName = orderForm.customerName
            }) == Response.Success ? "Ok" : "ERROR");
        }
Exemplo n.º 7
0
        public ContentResult GetNewOrderTemplate(int contractId)
        {
            var legalId      = contractLogic.GetContract(contractId).LegalId;
            var contractorId = legalLogic.GetLegal(legalId).ContractorId.Value;

            // проверка прав участника
            if (!participantLogic.IsAllowedActionByContractor(37, legalLogic.GetLegal(contractorId).ContractorId.Value, CurrentUserId))
            {
                return(Content(JsonConvert.SerializeObject(new { ActionId = 37, Message = "У вас недостаточно прав на выполнение этого действия." })));
            }

            // подстановка значений по-умолчанию
            var c = new OrderTemplate {
                ContractId = contractId
            };

            return(Content(JsonConvert.SerializeObject(c)));
        }
Exemplo n.º 8
0
        public async Task <ActionResult <Reciept> > OrderCake(string name, OrderTemplate model)
        {
            if (name == null)
            {
                return(NotFound("Enter name of cake"));
            }
            var getcake = await cake.GetCake(name);

            model.Amount = getcake.Price;
            var reference = await InitializeTransaction(model);

            var newcontent = await Verify(reference);

            Reciept reciept = JsonConvert.DeserializeObject <Reciept>(newcontent);

            if (reciept != null)
            {
                return(Ok(reciept));
            }
            return(BadRequest("Try again"));
        }
Exemplo n.º 9
0
        private async Task <string> InitializeTransaction(OrderTemplate model)
        {
            try {
                var client = GetClient();
                var url    = urlBase + "/initialize";
                HttpResponseMessage httpResponse;
                var json = JsonConvert.SerializeObject(model);
                using (StringContent content = new StringContent(json))
                {
                    content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    httpResponse = await client.PostAsync(url, content);
                }
                var newContent = await GetContent(httpResponse);

                Verification verify = JsonConvert.DeserializeObject <Verification>(newContent);
                return(verify.Data.Reference);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Exemplo n.º 10
0
 public void Customize(IFixture fixture)
 {
     fixture.Register(() => { return(OrderTemplate.GetWithSingleItem()); });
     fixture.Register(() => { return(OrderRequestTemplate.Get()); });
 }
Exemplo n.º 11
0
 public void Import(int id)
 {
     var    order    = _thisDAL.Query(id);
     var    details  = _orderDetailDal.QueryByParent(id).ToList();
     string fileName = OrderTemplate.Create(order, details);
 }
Exemplo n.º 12
0
 public void Customize(IFixture fixture)
 {
     fixture.Register(() => { return(OrderTemplate.GetWithTwoItems()); });
 }