コード例 #1
0
        public ActionResult Create1Step(long LeadId, long ProjectId, Lead model)
        {
            // Ищем или создаем лида, к которому создается заказ
            Lead lead;
            if (LeadId != -1)
            {
                lead = DataContext.Leads.FirstOrDefault(l => l.Id == LeadId);
                if (lead == null)
                {
                    ShowError("Такой лид не найден");
                    return RedirectToAction("Create");
                }
            }
            else
            {
                model.DateCreated = DateTime.Now;
                DataContext.Leads.InsertOnSubmit(model);
                lead = model;
            }

            // создаем заказ
            var order = new LeadOrder()
            {
                DateCreated = DateTime.Now,
                User = CurrentUser,
                DeliveryType = (short)DeliveryTypes.Self,
                PaymentType = (short)PaymentTypes.BankPayment,
                Status = (short)LeadOrderStatus.Initial,
                ProjectId = ProjectId
            };

            // Создаем первоначальные данные по истории заявки
            order.LeadOrderChangements.Add(new LeadOrderChangement()
            {
                AuthorId = CurrentUser.Id,
                LeadOrder = order,
                DateCreated = DateTime.Now,
                NewStatus = (short)LeadOrderStatus.Initial,
                Comments = "Создание заказа пользователем " + CurrentUser.GetFio()
            });

            lead.LeadOrders.Add(order);
            DataContext.SubmitChanges();

            ShowSuccess(string.Format("Заказ №{0} успешно создан для лида {1}", order.Id, lead.ToString()));

            return RedirectToAction("EditOrderItems", new { id = order.Id });
        }
コード例 #2
0
		private void attach_LeadOrders(LeadOrder entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}
コード例 #3
0
		private void detach_LeadOrders(LeadOrder entity)
		{
			this.SendPropertyChanging();
			entity.Warehouse = null;
		}
コード例 #4
0
		private void detach_LeadOrders(LeadOrder entity)
		{
			this.SendPropertyChanging();
			entity.Project = null;
		}