Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _CurrentUser = SwitchUserManager.GetCurrentUser();
        _AllAreas    = AreaItemManager.GetAll();
        _AllShops    = ShopItemManager.GetAll();

        if (Page.IsPostBack == false)
        {
            string AES_OrderItemId = Server.UrlDecode(Request.QueryString.ToString());
            if (string.IsNullOrWhiteSpace(AES_OrderItemId))
            {
                _IsUpdateMode     = false;
                _CurrentOrderItem = new OrderItem(null, null, null, DateTime.Now.Date, "");
            }
            else
            {
                _IsUpdateMode     = true;
                _CurrentOrderItem = OrderItemManager.GetById(decimal.Parse(LeftHand.Gadget.Encoder.AES_Decryption(AES_OrderItemId)));
            }
        }
    }
Ejemplo n.º 2
0
        public void LoadByOrderIdTest()
        {
            List <OrderItem> items = OrderItemManager.LoadByOrderId(2);

            Assert.AreEqual(1, items.Count);
        }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            List <string> Errors = new List <string>();

            if (Page.IsPostBack == false)
            {
                _StateTypes = new List <StateType>();
                _StartDate  = DateTime.Now.Date.AddDays(-1 * DateTime.Now.Day + 1);
                _EndDate    = _StartDate.AddMonths(1).AddSeconds(-1).Date;
            }
            else
            {
                //StateType
                _StateTypes = new List <StateType>();
                foreach (ListItem ListItem in this.vStateTypeList.Items)
                {
                    if (ListItem.Selected == false)
                    {
                        continue;
                    }

                    _StateTypes.Add((StateType)Enum.Parse(typeof(StateType), ListItem.Text.Trim()));
                }

                //SateRange
                DateTime StartDate;
                if (DateTime.TryParse(this.vStartDate.Text.Trim(), out StartDate) == false)
                {
                    Errors.Add("開始時間錯誤");
                }
                else
                {
                    _StartDate = StartDate;
                }

                DateTime EndDate;
                if (DateTime.TryParse(this.vEndDate.Text.Trim(), out EndDate) == false)
                {
                    Errors.Add("結束時間錯誤");
                }
                else
                {
                    _EndDate = EndDate.AddDays(1).AddSeconds(-1);
                }


                if (_StartDate >= _EndDate)
                {
                    _EndDate = _StartDate.AddDays(1).AddSeconds(-1);
                    Errors.Add("結束時間不可早於開始時間");
                }
            }

            if (Errors.Count > 0)
            {
                _OrderItems = new List <OrderItem>();
                throw new Exception(string.Join("\\r\\n", Errors));
            }
            else
            {
                _OrderItems = OrderItemManager.GetBySearch(_StateTypes, _StartDate, _EndDate.AddDays(1));
            }
        }
        catch (Exception ex)
        {
            LeftHand.Gadget.Dialog.Alert(ex.Message);
        }
    }
Ejemplo n.º 4
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            this.vMemberName.Text    = _CurrentOrderItem.MemberName;
            this.vMemberAccount.Text = _CurrentOrderItem.MemberAccount;
            this.vMemberPhone.Text   = _CurrentOrderItem.MemberPhone;
        }

        //vAreaSelector
        this.vAreaSelector.Items.Clear();
        this.vAreaSelector.Items.Add(new ListItem("請選擇", ""));
        this.vAreaSelector.Items.AddRange(_AllAreas.Select(a => new ListItem(a.Name, a.Id)).ToArray());
        ListItem AreaListItem = this.vAreaSelector.Items.FindByText(_CurrentOrderItem.MemberArea);

        if (AreaListItem != null)
        {
            AreaListItem.Selected = true;
        }

        //vSchoolSelector
        this.vSchoolSelector.Items.Clear();
        this.vSchoolSelector.Items.Add(new ListItem("請選擇", ""));
        this.vSchoolSelector.Items.AddRange(SchoolItemManager.GetByArea(AreaItemManager.GetByName(_CurrentOrderItem.MemberArea)).Select(a => new ListItem(a.Name, a.Id)).ToArray());
        ListItem SchoolListItem = this.vSchoolSelector.Items.FindByText(_CurrentOrderItem.MemberSchool);

        if (SchoolListItem != null)
        {
            SchoolListItem.Selected = true;
        }

        //vShopList
        this.vShopList.DataSource = ShopItemManager.GetBySchool(SchoolItemManager.GetByName(_CurrentOrderItem.MemberSchool));
        this.vShopList.DataBind();

        //Calandar
        DateTime MinDate       = DateTime.Now.Date.AddDays(1);
        string   MinDateString = string.Format("new Date({0},{1},{2})", MinDate.Year, MinDate.Month - 1, MinDate.Day);

        DateTime MaxDate       = DateTime.Now.AddDays(60).Date;
        string   MaxDateString = string.Format("new Date({0},{1},{2})", MaxDate.Year, MaxDate.Month - 1, MaxDate.Day);

        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "BindCalander", string.Format("BindCalander({0},{1});", MinDateString, MaxDateString), true);

        if (string.IsNullOrWhiteSpace(this.vSelectedDate.Value) == false)
        {
            _CurrentOrderItem.OrderDate = DateTime.Parse(this.vSelectedDate.Value).Date;
        }

        //RoundList
        ShopItem SelectedShop = ShopItemManager.GetById(_CurrentOrderItem.ShopId);

        if (SelectedShop != null && SelectedShop.RoundItems != null && _CurrentOrderItem.OrderDate != null)
        {
            //還沒有額滿的回合,包含當日還沒有愈時的
            List <RoundItem> NotFullRounds = new List <RoundItem>();

            Dictionary <string, int> RoundCount = OrderItemManager.GetRoundCount(_CurrentOrderItem.ShopId, (DateTime)_CurrentOrderItem.OrderDate);
            foreach (RoundItem Round in SelectedShop.RoundItems)
            {
                DateTime OrderDate = (DateTime)_CurrentOrderItem.OrderDate;

                if (OrderDate <= DateTime.Now && Round.StartTime < DateTime.Now.TimeOfDay)
                {
                    continue;
                }
                if (RoundCount.ContainsKey(Round.Name) == false)
                {
                    NotFullRounds.Add(Round); continue;
                }
                if (RoundCount[Round.Name] < Round.LimitPairAmount == true)
                {
                    NotFullRounds.Add(Round); continue;
                }
            }

            if (NotFullRounds.Count > 0)
            {
                this.vNoRound.Text = "";

                this.vRoundList.DataSource = NotFullRounds;
                this.vRoundList.DataBind();
            }
            else
            {
                this.vNoRound.Text = "所有時段都已被預訂,請選擇其他日期或其他分店。";

                this.vRoundList.DataSource = null;
                this.vRoundList.DataBind();
            }
        }

        this.vSendButton.Text = "下一步";

        //Bind_IdCardNumberCheck
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Bind_IdCardNumberCheck", "Bind_IdCardNumberCheck();", true);
    }
Ejemplo n.º 5
0
 public OrderController()
 {
     productManager   = new ProductManager();
     orderManager     = new OrderManager();
     orderItemManager = new OrderItemManager();
 }
Ejemplo n.º 6
0
    //送出預約
    protected void vSendButton_Click(object sender, EventArgs e)
    {
        try
        {
            //檢查是否所有資都填了
            List <string> Errors = new List <string>();

            #region MemberInfo

            //vMemberName
            string MemberName = this.vMemberName.Text.Replace(" ", "");
            if (string.IsNullOrWhiteSpace(MemberName) == true)
            {
                Errors.Add("請輸入 大學生姓名");
            }

            //MemberIdCardNumber
            string MemberIdCardNumber = this.vMemberAccount.Text.Replace(" ", "").ToUpper();
            if (string.IsNullOrWhiteSpace(MemberIdCardNumber) == true)
            {
                Errors.Add("請輸入 身分證字號");
            }
            else if (UserManager.IdCheck(MemberIdCardNumber) == false)
            {
                Errors.Add("身分證字號m錯誤");
            }
            else if (ConfigManager.GetByConfigKey(ConfigKey.黑名單).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Contains(MemberIdCardNumber) == true)
            {
                Errors.Add("身份證字號無效");
            }

            //vMemberPhone
            string MemberPhone = this.vMemberPhone.Text.Replace(" ", "");
            if (string.IsNullOrWhiteSpace(MemberPhone) == true)
            {
                Errors.Add("請輸入 行動電話");
            }
            else if (MemberPhone.Contains("09") == false)
            {
                Errors.Add("行動電話格式不正確");
            }

            #endregion

            #region MemberArea

            string Area = this.vAreaSelector.SelectedItem.Text;
            if (Area == "請選擇")
            {
                Errors.Add("請選擇 地區");
            }

            string School = this.vSchoolSelector.SelectedItem.Text;
            if (School == "請選擇")
            {
                Errors.Add("請選擇 學校");
            }

            #endregion

            #region ShopInfos

            if (string.IsNullOrWhiteSpace(_CurrentOrderItem.ShopId) == true)
            {
                Errors.Add("請選擇 預約LOHAS門市");
            }
            else if (string.IsNullOrWhiteSpace(_CurrentOrderItem.ShopName) == true)
            {
                Errors.Add("請選擇 預約LOHAS門市");
            }
            else if (string.IsNullOrWhiteSpace(_CurrentOrderItem.ShopPhone) == true)
            {
                Errors.Add("請選擇 預約LOHAS門市");
            }
            else if (string.IsNullOrWhiteSpace(_CurrentOrderItem.ShopAddress) == true)
            {
                Errors.Add("請選擇 預約LOHAS門市");
            }
            else if (string.IsNullOrWhiteSpace(_CurrentOrderItem.Shoplatitude) == true)
            {
                Errors.Add("請選擇 預約LOHAS門市");
            }
            else if (string.IsNullOrWhiteSpace(_CurrentOrderItem.Shoplongitude) == true)
            {
                Errors.Add("請選擇 預約LOHAS門市");
            }

            #endregion

            #region OrderRound

            DateTime OrderDate;
            if (DateTime.TryParse(this.vSelectedDate.Value.Trim(), out OrderDate) == false)
            {
                Errors.Add("請選擇 預約日期");
            }

            if (string.IsNullOrWhiteSpace(_CurrentOrderItem.OrderRound) == true)
            {
                Errors.Add("請選擇 預約時段");
            }
            #endregion

            if (Errors.Count > 0)
            {
                throw new Exception(string.Join("\\r\\n", Errors));
            }

            //檢查 重複報名
            if (_IsUpdateMode == false && OrderItemManager.Get(MemberIdCardNumber, MemberPhone) != null)
            {
                Errors.Add("每人僅有一次機會,不可重複預約");
            }

            if (Errors.Count > 0)
            {
                throw new Exception(string.Join("\\r\\n", Errors));
            }


            //檢查 是否額滿
            int SameRoundOrderAmount = OrderItemManager.GetRoundCount(_CurrentOrderItem.ShopId, (DateTime)_CurrentOrderItem.OrderDate, _CurrentOrderItem.OrderRound);
            int LimitPairAmount      = ShopItemManager.GetById(_CurrentOrderItem.ShopId).RoundItems.FirstOrDefault(r => r.Name == _CurrentOrderItem.OrderRound).LimitPairAmount;
            if ((SameRoundOrderAmount + 1) > LimitPairAmount)
            {
                Errors.Add("場次已經額滿,請挑選新的場次");
            }

            if (Errors.Count > 0)
            {
                throw new Exception(string.Join("\\r\\n", Errors));
            }

            _CurrentOrderItem.MemberName    = MemberName;
            _CurrentOrderItem.MemberAccount = MemberIdCardNumber;
            _CurrentOrderItem.MemberPhone   = MemberPhone;

            _CurrentOrderItem.MemberArea   = Area;
            _CurrentOrderItem.MemberSchool = School;

            _CurrentOrderItem.OrderDate = OrderDate;

            OrderItemManager.SaveTemp(_CurrentOrderItem);
            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Message", "top.location.replace('Questionnaire_Form.aspx');", true);

            //OrderItemManager.Save(_CurrentOrderItem);
            //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Message", "top.location.replace('Finish_Form.aspx?" + Server.UrlEncode(LeftHand.Gadget.Encoder.AES_Encryption(_CurrentOrderItem.Id.ToString())) + "');", true);
        }
        catch (Exception ex)
        {
            LeftHand.Gadget.Dialog.Alert(ex.Message);
        }
    }
Ejemplo n.º 7
0
 public void LoadByOrderID()
 {
     Assert.IsTrue(OrderItemManager.LoadByOrderId(5).Count == 3);
 }
Ejemplo n.º 8
0
 public void Seed()
 {
     bool result = OrderItemManager.Seed();
     Assert.IsTrue(result);
 }
Ejemplo n.º 9
0
        public static void RegisterTypes(IUnityContainer container)
        {
            container.RegisterType <IConfiguration, DefaultChillinConfiguration>();
            var config = container.Resolve <IConfiguration>();

            var elasticClientSettings = new ConnectionSettings(new System.Uri(config.ElasticSearchUrl));

            elasticClientSettings.DefaultIndex(config.ElasticSearchIndex);
            var elasticClient = new ElasticClient(elasticClientSettings);

            container.RegisterInstance(typeof(IContentService), ApplicationContext.Current.Services.ContentService);
            container.RegisterInstance(typeof(IMediaService), ApplicationContext.Current.Services.MediaService);
            container.RegisterInstance <IElasticClient>(elasticClient);

            container.RegisterType <IExchangeMailWebApi, ExchangeMailWebApi>();
            container.RegisterType <ISourceFactory, ChalmersSourceFactory>();
            container.RegisterType <IMediaItemManager, BlobStorageMediaItemManager>();
            container.RegisterType <IMediaItemManager, UmbracoMediaItemManager>("Legacy");
            container.RegisterType <IOrderItemSearcher, ElasticSearchOrderItemSearcher>();
            container.RegisterType <ITemplateService, ElasticsearchTemplateService>();
            container.RegisterType <IAffiliationDataProvider, SolrLibcdksAffiliationDataProvider>();

            container.RegisterType <IJsonService, JsonService>();
            container.RegisterType <IFolioItemService, FolioItemService>();
            container.RegisterType <IFolioRepository, FolioRepository>();
            container.RegisterType <IFolioService, FolioService>();
            container.RegisterType <IFolioInstanceService, FolioInstanceService>();
            container.RegisterType <IFolioHoldingService, FolioHoldingService>();
            container.RegisterType <IFolioCirculationService, FolioCirculationService>();
            container.RegisterType <IChillinTextRepository, ChillinTextRepository>();
            container.RegisterType <IFolioUserService, FolioUserService>();

            var templateService         = container.Resolve <ITemplateService>();
            var affiliationDataProvider = container.Resolve <IAffiliationDataProvider>();

            // Create all our singleton type instances.
            var mailService            = new MailService(container.Resolve <IMediaItemManager>(), container.Resolve <IExchangeMailWebApi>());
            var notifier               = new Notifier();
            var umbraco                = new UmbracoWrapper();
            var orderItemManager       = new EntityFrameworkOrderItemManager(umbraco, container.Resolve <IOrderItemSearcher>());
            var legacyOrderItemManager = new OrderItemManager(umbraco);
            var providerService        = new ProviderService(container.Resolve <IOrderItemSearcher>());
            var bulkDataManager        = new BulkDataManager(container.Resolve <IOrderItemSearcher>());

            // Connect instances that depend on eachother.
            notifier.SetOrderItemManager(orderItemManager, umbraco);
            orderItemManager.SetNotifier(notifier);

            // Hook up everything that is needed for us to function.
            container.RegisterInstance(typeof(UmbracoContext), UmbracoContext.Current);
            container.RegisterInstance(typeof(IMemberInfoManager), new MemberInfoManager());
            container.RegisterInstance(typeof(IUmbracoWrapper), umbraco);
            container.RegisterInstance(typeof(INotifier), notifier);
            container.RegisterInstance(typeof(IOrderItemManager), orderItemManager);
            container.RegisterInstance <IOrderItemManager>("Legacy", legacyOrderItemManager);
            container.RegisterInstance(typeof(IAutomaticMailSendingEngine), new AutomaticMailSendingEngine(container.Resolve <IOrderItemSearcher>(), templateService, orderItemManager, mailService));
            container.RegisterInstance(typeof(IMailService), mailService);
            container.RegisterInstance(typeof(IProviderService), providerService);
            container.RegisterInstance(typeof(IBulkDataManager), bulkDataManager);
            container.RegisterInstance <IPatronDataProvider>(new FolioPatronDataProvider(templateService, affiliationDataProvider).Connect());
        }
Ejemplo n.º 10
0
    protected void vSendButton_Click(object sender, EventArgs e)
    {
        try
        {
            List <string> Errors = new List <string>();

            #region QuestionResult;

            string QuestionResult         = "";
            int    QuestionnaireItemIndex = 0;
            foreach (RepeaterItem RepeaterItem in this.vQuestionnaire_List.Items)
            {
                QuestionnaireItem QuestionnaireItem = _QuestionnaireItems[QuestionnaireItemIndex];

                switch (QuestionnaireItem.OptionType)
                {
                case OptionType.單選:
                    RadioButtonList vRadioButtonList = (RadioButtonList)RepeaterItem.FindControl("vRadioButtonList");

                    if (string.IsNullOrWhiteSpace(vRadioButtonList.SelectedValue))
                    {
                        Errors.Add(string.Format("請填寫第{0}題的答案", QuestionnaireItem.Sort));
                    }
                    QuestionResult += string.Format("{0}:{1}<br />", QuestionnaireItem.ShortTitle, vRadioButtonList.SelectedValue);
                    break;

                case OptionType.多選:
                    CheckBoxList vCheckBoxList = (CheckBoxList)RepeaterItem.FindControl("vCheckBoxList");

                    if (string.IsNullOrWhiteSpace(vCheckBoxList.SelectedValue))
                    {
                        Errors.Add(string.Format("請填寫第{0}題的答案", QuestionnaireItem.Sort));
                    }
                    QuestionResult += string.Format("{0}:{1}<br />", QuestionnaireItem.ShortTitle, vCheckBoxList.SelectedValue);
                    break;

                case OptionType.單行文字方塊:
                    List <string> OptionResult = new List <string>();

                    Repeater vTextBoxList = (Repeater)RepeaterItem.FindControl("vTextBoxList");
                    foreach (RepeaterItem TextBoxItem in vTextBoxList.Items)
                    {
                        string Option = ((TextBox)TextBoxItem.FindControl("vResult")).Text.Trim().Replace(" ", "");
                        if (string.IsNullOrWhiteSpace(Option))
                        {
                            Errors.Add(string.Format("請填寫第{0}題第{1}項的答案", QuestionnaireItem.Sort, TextBoxItem.ItemIndex + 1));
                        }

                        OptionResult.Add(Option);
                    }

                    QuestionResult += string.Format("{0}:{1}<br />", QuestionnaireItem.ShortTitle, string.Join(",", OptionResult));
                    break;
                }

                QuestionnaireItemIndex += 1;
            }

            #endregion

            #region vSystemRemark;

            string SystemRemark = this.vSystemRemark.Value.Trim();

            #endregion

            if (Errors.Count > 0)
            {
                throw new Exception(string.Join("\\r\\n", Errors));
            }

            _CurrentOrderItem.QuestionResult = QuestionResult;
            _CurrentOrderItem.SyatemRemark   = SystemRemark;

            OrderItemManager.Save(_CurrentOrderItem);
            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Message", "top.location.replace('Finish_Form.aspx');", true);
        }
        catch (Exception ex)
        {
            LeftHand.Gadget.Dialog.Alert(ex.Message);
        }
    }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            ICampaignService  campaignService  = new CampaignManager();
            ICustomerService  customerService  = new CustomerManager(new MernisServiceAdapter());
            IOrderItemService orderItemService = new OrderItemManager();
            IOrderService     orderService     = new OrderManager(orderItemService);
            IProductService   productService   = new ProductManager();


            Customer customer = new Customer()
            {
                Id          = 1,
                TcNumber    = "27595144254",
                FirstName   = "Gökçenur",
                LastName    = "Zenginal",
                DateOfBirth = new DateTime(1993, 8, 23)
            };

            Customer customer2 = new Customer()
            {
                Id          = 2,
                TcNumber    = "12345978912",
                FirstName   = "test2",
                LastName    = "test2",
                DateOfBirth = new DateTime(1993, 1, 23)
            };

            Product product = new Product()
            {
                Id    = 1,
                Nane  = "Product 1",
                Price = 15
            };

            Campaign campaign = new Campaign()
            {
                Id       = 1,
                Nane     = "Campaign 1",
                Discount = 50
            };

            Campaign campaign2 = new Campaign()
            {
                Id       = 1,
                Nane     = "Campaign 2",
                Discount = 15
            };

            Console.WriteLine("****************Oyuncu ekleme****************");
            customerService.Add(customer);
            Console.WriteLine();

            Console.WriteLine("****************Oyuncu güncelleme****************");
            customer.FirstName = "test3";
            customerService.Update(customer);
            Console.WriteLine();

            Console.WriteLine("****************Oyuncu silme****************");
            customerService.Delete(customer2);
            Console.WriteLine();

            Console.WriteLine("****************Oyun satışı****************");
            orderService.Add(customer, product, 2);
            Console.WriteLine();

            Console.WriteLine("****************Kampanya ekleme****************");
            campaignService.Add(campaign);
            Console.WriteLine();

            Console.WriteLine("****************Kampanya güncelleme****************");
            campaign.Discount = 25;
            campaignService.Update(campaign);
            Console.WriteLine();

            Console.WriteLine("****************Kampanya silme****************");
            campaignService.Delete(campaign2);
            Console.WriteLine();

            Console.WriteLine("****************Kampanyalı Oyun satışı****************");
            orderService.Add(customer, product, 2, campaign);
            Console.WriteLine();

            Console.ReadLine();
        }
Ejemplo n.º 12
0
 // DELETE: api/OrderItem/5
 public void Delete(Guid id)
 {
     OrderItemManager.Delete(id);
 }
Ejemplo n.º 13
0
 // PUT: api/OrderItem/5
 public void Put(Guid id, [FromBody] OrderItem make)
 {
     OrderItemManager.Update(make);
 }
Ejemplo n.º 14
0
 // GET: api/OrderItem/5
 public OrderItem Get(Guid id)
 {
     return(OrderItemManager.LoadById(id));;
 }
Ejemplo n.º 15
0
 // GET: api/OrderItem
 public IEnumerable <OrderItem> Get()
 {
     return(OrderItemManager.Load());
 }