Пример #1
0
        public ActionResult Filter(AdSearchViewModel collection, string id = "")
        {
            WorksSearchModel value = new WorksSearchModel()
            {
                Budget         = collection.Budget,
                MaxDeep        = collection.MaxDeep,
                MaxHeight      = collection.MaxHeight,
                MaxLength      = collection.MaxLength,
                MaxPrice       = collection.Price_U,
                MaxTimeLength  = collection.MaxTimeLength,
                MaxWidth       = collection.MaxWidth,
                MineDeep       = collection.MineDeep,
                MineHeight     = collection.MineHeight,
                MineLength     = collection.MineLength,
                MinePrice      = collection.Price_L,
                MineTimeLength = collection.MineTimeLength,
                MineWidth      = collection.MineWidth,
                WorksName      = collection.WorksName,
                StyleNoList    = collection.StyleNoList,
                AuthorNoList   = collection.AuthorNoList,
                GenreNoList    = collection.GenreNoList,
                GradedNoList   = collection.GradedNoList,
                OrderbyType    = MenuModel.WorkOrderbyTypeEnum.稱姓名小至大
            };
            PackagesModel pm = new PackagesModel();

            if (string.IsNullOrEmpty(id))
            {
                pm.PackagesName = "未命名" + DateTime.Now.ToString("yyMMddHHmmss");
                short d = 1;
                Int16.TryParse(SystemGeneralModel.GetConfigure(SystemGeneralModel.ConfigureClassEnum.OpenDays.ToString()).ConfigureContent, out d);
                pm.EndDate = DateTime.Now.AddDays(d);
                pm.Create();
                id = pm.PackagesNo;
            }
            pm = PackagesModel.GetPackageDetail(id);
            pm.PackagesName = "";
            // 將搜尋結果加入PackagesModel 的WorksNos
            var model = value.Search();

            for (int i = 0; i < model.Count; i++)
            {
                pm.PackageItems.Add(new PackagesModel.PackageItemModel()
                {
                    WorksNo = model[i].WorksNo,
                    IsJoin  = "N"
                });
            }
            pm.SearchJson = JsonConvert.SerializeObject(value);
            pm.Budget     = collection.Budget;
            pm.Update();

            //儲存篩選條件
            return(RedirectToAction("Edit_WorksList", new { id = pm.PackagesNo }));
        }
Пример #2
0
        public ActionResult Edit(string id, PackageViewModel collection)
        {
            //try
            //{
            PackagesModel value = new PackagesModel();

            value = PackagesModel.GetPackageDetail(collection.PG_No);
            value.PackagesName = collection.PG_Name;
            value.EndDate      = collection.EndDate;
            value.PackagesMemo = collection.Remark ?? "";
            value.Budget       = collection.Budget;
            value.Update();
            ViewData["Message"] = "儲存成功";

            collection.Url       = this.Url.Action("Detail_Works", "Package", new { id = id }, this.Request.Url.Scheme);
            collection.QRImg     = PackagesModel.DrawQRcodeToImgBase64sting(this.Url.Action("Detail_Works", "Package", new { id = id }, this.Request.Url.Scheme));
            collection.WorksList = new List <WorksInfoViewModel>();
            var valueistem = PackagesModel.ReturnPackageItemList(id, true);

            for (int i = 0; i < valueistem.Count; i++)
            {
                collection.WorksList.Add(new WorksInfoViewModel()
                {
                    //No = valueistem[i].WorksNo,
                    Author = valueistem[i].AuthorsName,
                    //MiniImgBase64 = valueistem[i].WorksImgBase64,
                    //MedImg = valueistem[i].WorksImg_m,
                    //MiniImgID = valueistem[i].WorksImgID,
                    Name  = valueistem[i].WorksName,
                    Price = valueistem[i].Price.ToString("#,#"),
                    Years = valueistem[i].Year,
                    Cost  = valueistem[i].Cost.ToString("#,#")
                });
                collection.Summary += valueistem[i].Price;
            }
            return(View(collection));
            //}
            //catch
            //{
            //    return Json("儲存失敗");
            //}
        }