コード例 #1
0
ファイル: OutDoorController.cs プロジェクト: navy235/WebSite
 public ActionResult AddAuctionCalendar(int id, string startTime, string endTime)
 {
     List<AuctionCalendarViewModel> data = new List<AuctionCalendarViewModel>();
     DateTime _startTime = Convert.ToDateTime(startTime);
     DateTime _endtime = Convert.ToDateTime(endTime);
     AuctionCalendar model = new AuctionCalendar();
     if (auctionCalendarService.ValidateAuction(id, _startTime, _endtime))
     {
         model = new AuctionCalendar()
           {
               MediaID = id,
               StartTime = _startTime,
               EndTime = _endtime
           };
         auctionCalendarService.Create(model);
     }
     data.AddRange(GetAuctionCalendarViewModel(model));
     return Json(data);
 }
コード例 #2
0
        public List<AuctionCalendarViewModel> GetAuctionCalendarViewModel(AuctionCalendar model)
        {
            List<AuctionCalendarViewModel> data = new List<AuctionCalendarViewModel>();
            bool hasTwo = false;
            var CurrentYear = DateTime.Now.Year;
            var currentYearFirtDay = new DateTime(CurrentYear, 1, 1);
            var NextYear = DateTime.Now.Year + 1;
            var nextYearFirtDay = new DateTime(NextYear, 1, 1);
            if (model.StartTime < currentYearFirtDay)
            {
                model.StartTime = currentYearFirtDay;
            }
            if (model.StartTime.Year != model.EndTime.Year)
            {
                hasTwo = true;
            }
            if (!hasTwo)
            {
                AuctionCalendarViewModel item = new AuctionCalendarViewModel()
                {
                    ID = model.ID,
                    EndTime = model.EndTime.ToString("yyyy-MM-dd"),
                    EndDate = model.EndTime.ToString("MM-dd"),
                    MediaID = model.MediaID,
                    StartTime = model.StartTime.ToString("yyyy-MM-dd"),
                    StartDate = model.StartTime.ToString("MM-dd"),
                    Top = (model.EndTime < nextYearFirtDay)
                };
                if (item.Top)
                {
                    item.Left = (model.StartTime - currentYearFirtDay).Days;
                    item.Width = (model.EndTime - model.StartTime).Days;
                }
                else
                {
                    item.Left = (model.StartTime - nextYearFirtDay).Days;
                    item.Width = (model.EndTime - model.StartTime).Days;
                }
                data.Add(item);
            }
            else
            {

                AuctionCalendarViewModel item1 = new AuctionCalendarViewModel()
                {
                    ID = model.ID,
                    EndTime = model.EndTime.ToString("yyyy-MM-dd"),
                    EndDate = model.EndTime.ToString("MM-dd"),
                    MediaID = model.MediaID,
                    StartTime = model.StartTime.ToString("yyyy-MM-dd"),
                    StartDate = model.StartTime.ToString("MM-dd"),
                    Top = true,
                    HasTwo = true,
                    Left = (model.StartTime - currentYearFirtDay).Days,
                    ShowLeft = true,
                    Width = (new DateTime(CurrentYear, 12, 30) - model.StartTime).Days
                };

                AuctionCalendarViewModel item2 = new AuctionCalendarViewModel()
                {
                    ID = model.ID,
                    EndTime = model.EndTime.ToString("yyyy-MM-dd"),
                    EndDate = model.EndTime.ToString("MM-dd"),
                    MediaID = model.MediaID,
                    StartTime = model.StartTime.ToString("yyyy-MM-dd"),
                    StartDate = model.StartTime.ToString("MM-dd"),
                    Top = false,
                    HasTwo = true,
                    ShowLeft = false,
                    Left = 0,
                    Width = (model.EndTime - new DateTime(NextYear, 1, 1)).Days
                };
                data.Add(item1);
                data.Add(item2);
            }

            return data;
        }
コード例 #3
0
 public AuctionCalendar Create(AuctionCalendar model)
 {
     DB_Service.Add<AuctionCalendar>(model);
     DB_Service.Commit();
     return model;
 }