public ActionResult DeleteConfirmed(int id) { CalenderEvent calenderEvent = db.CalenderEvents.Find(id); db.CalenderEvents.Remove(calenderEvent); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// 傳入兩個陣列,回傳一個合併的陣列,完整複製 /// </summary> /// <param name="events1"></param> /// <param name="events2"></param> /// <returns></returns> public static CalenderEvent[] CombinEvents(CalenderEvent[] events1, CalenderEvent[] events2) { CalenderEvent[] combinedEvents = new CalenderEvent[events1.Length + events2.Length]; events1.CopyTo(combinedEvents, 0); events2.CopyTo(combinedEvents, events1.Length); // return combinedEvents; }
public ActionResult GetJsonShowsFollows() { var userId = User.Identity.GetUserId(); //var listOfMembers = membersDb.All.ToList(); //Member member = listOfMembers.Find(c => c.AccountUserId.Contains(userId)); Member member = membersDb.All.First(c => c.AccountUserId == userId); //var allshowinfos = showInfoDb.All.ToList(); //var followedShows = allshowinfos.FindAll(c => c.MemberId.Equals(member.MemberId)).ToList(); var followedShows = showInfoDb.All.Where(c => c.MemberId == member.MemberId).ToList(); List <CalenderEvent> calEvents = new List <CalenderEvent>(); foreach (var followed in followedShows) { var result = _tvdb.GetShow(followed.ShowId); var episodeList = result.Episodes; int id = 0; foreach (var episodes in episodeList) { //var allEpisodes = episodeInfoDb.All.ToList(); //var watchedEpisodes = allEpisodes.FindAll(c => c.ShowInfoId.Equals(followed.ShowInfoId)).ToList(); var watchedEpisodes = episodeInfoDb.All.Where(c => c.ShowInfoId == followed.ShowInfoId).ToList(); var dateAired = episodes.FirstAired; string watchedEpisodeInfoId = ""; string isWatched = "false"; string classNameEvent = "eventNotWatched"; if (watchedEpisodes.FirstOrDefault(c => c.ThetvdbEpisodeId == episodes.Id) != null) { watchedEpisodeInfoId = watchedEpisodes.First(c => c.ThetvdbEpisodeId == episodes.Id).EpisodeInfoId.ToString(); isWatched = "true"; classNameEvent = "eventWatched"; } CalenderEvent cEvent = new CalenderEvent() { allday = "", title = result.Name + "\n" + "(" + episodes.SeasonNumber + "x" + episodes.EpisodeNumber + ")" + episodes.Title, id = id.ToString(), //start = dateAired.GetValueOrDefault().Year + "-" // + dateAired.GetValueOrDefault().Month + "-" // + dateAired.GetValueOrDefault().Day, start = dateAired.GetValueOrDefault().ToString("yyyy-MM-dd"), className = classNameEvent, completed = isWatched, thetvdbepisodeid = episodes.Id.ToString(), showinfoid = followed.ShowInfoId.ToString(), episodeinfoid = watchedEpisodeInfoId }; //System.Console.WriteLine(cEvent.start); calEvents.Add(cEvent); id++; } } return(Json(calEvents, JsonRequestBehavior.AllowGet)); }
public IEnumerable<CalenderEvent> GetCalenderMonth() { var dummyData = new CalenderEvent[] { new CalenderEvent() { id = "262399c4-3d9c-4d4f-b090-c8d8e8b50358", title = "ガス代", description="3,750円", start = "2021-03-10T13:00:00", end = "2021-03-10T13:00:00"}, new CalenderEvent() { id = "3a05c506-3e5a-4e33-bd9e-e2a92ae37e27", title = "食費", description="12,870円", start = "2021-03-13T11:30:00", end = "2021-03-13T11:30:00", color = "#257e4a"}, }; var result = from d in dummyData select d; return result; }
public ActionResult Edit([Bind(Include = "EventID,Title,StartDate,EndDate,StartTime,EndTime,Category,Description")] CalenderEvent calenderEvent) { if (ModelState.IsValid) { db.Entry(calenderEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(calenderEvent)); }
public ActionResult Create([Bind(Include = "EventID,Title,StartDate,EndDate,StartTime,EndTime,Category,Description")] CalenderEvent calenderEvent) { if (ModelState.IsValid) { db.CalenderEvents.Add(calenderEvent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(calenderEvent)); }
// GET: CalenderEvents/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CalenderEvent calenderEvent = db.CalenderEvents.Find(id); if (calenderEvent == null) { return(HttpNotFound()); } return(View(calenderEvent)); }
public void Map_FromCalendarEventToForm_ReturnCorrectedValues() { // Arrange var calenderEvent = new CalenderEvent { Date = new DateTime(2018, 08, 31, 17, 35, 54), Title = "Friday party" }; var projection = new AutoMapProjection(); // Act var result = projection.Map(calenderEvent); // Assert result.EventDate.Should().Be(new DateTime(2018, 08, 31)); result.EventHour.Should().Be(17); result.EventMinute.Should().Be(35); result.Title.Should().Be("Friday party"); }
public CalenderEvent CreateCalenderEvent(CalenderEvent ce) { ctx.CalenderEvents.Add(ce); ctx.SaveChanges(); return(ce); }
public CalenderEvent GetCalenderEventById(int id) { CalenderEvent ce = ctx.CalenderEvents.ToList().Find(x => x.Id == id); return(ce); }
/// <summary> /// 測試數值型別及參考型別 /// </summary> /// <returns></returns> public ActionResult Process6() { List<CalenderEvent> events = new List<CalenderEvent>(); List<CalenderEvent> events2 = new List<CalenderEvent>(); CalenderEvent newEvent = new CalenderEvent() { Title = "", StartTime = new DateTimeOffset(2009, 7, 14, 19, 15, 00, TimeSpan.Zero), Duration = TimeSpan.FromHours(1) }; events.Add(newEvent); //新增到指定位置 events.Insert(1, newEvent); //將同樣的List加進去 events.AddRange(events2); //使用不存任何元素的陣列模式 Indexable ix = new Indexable(); ix[42] = "Xyzzy"; //使用泛型(T) ArrayAndIndexer<int> aai = new ArrayAndIndexer<int>(); aai.TheArray[10] = 42; aai[20] = 99; //使用泛型(T)及struct ArrayAndIndexer<CanChange> aaq = new ArrayAndIndexer<CanChange>(); aaq.TheArray[10].Number = 42; aaq[20] = new CanChange { Number = 99, Name = "My Item" }; //因struct是value type,因此無法修改class裡的值 CanChange elem = aaq[20]; elem.Number = 456; // return Content(aaq[10].Number + "_" + aaq[20].Number + "_" + elem.Number); }
/// <summary> /// 建立參考同一個Class的Array /// </summary> /// <returns></returns> public ActionResult Process2() { CalenderEvent theOnlyEvent = new CalenderEvent() { Title = "Swing Dancing at the South Bank", StartTime = new DateTimeOffset(2009, 7, 11, 15, 00, 00, TimeSpan.Zero), Duration = TimeSpan.FromHours(4) }; CalenderEvent[] events = { theOnlyEvent, theOnlyEvent, theOnlyEvent, theOnlyEvent, theOnlyEvent }; return View(); }
/// <summary> /// 傳入一個陣列,回傳一個合併的陣列,排除第一個元素 /// </summary> /// <param name="events"></param> /// <returns></returns> public static CalenderEvent[] RemoveFirstEvent(CalenderEvent[] events) { CalenderEvent[] croppedEvents = new CalenderEvent[events.Length - 1]; Array.Copy(events, //複製來源 1, //起始點 croppedEvents, //複製目地 0, //複製目地起始點 events.Length - 1 //複製數量 ); return croppedEvents; }
/// <summary> /// 回傳二維陣列 /// </summary> /// <param name="allEvents"></param> /// <param name="firstDay"></param> /// <param name="numberOfDays"></param> /// <returns></returns> public static CalenderEvent[][] GetEventsByDay(CalenderEvent[] allEvents, DateTime firstDay, int numberOfDays) { CalenderEvent[][] eventsByDay = new CalenderEvent[numberOfDays][]; for (int day = 0; day < numberOfDays; day++) { DateTime dateOfInterest = (firstDay + TimeSpan.FromDays(day)).Date; CalenderEvent[] itemsOnDateOfInterest = Array.FindAll(allEvents, e => e.StartTime.Date == dateOfInterest); eventsByDay[day] = itemsOnDateOfInterest; } return eventsByDay; }
public CalenderEvent CreateNewCalenderEvent([FromBody] CalenderEvent ce) { CalenderEvent nce = dao.CreateCalenderEvent(ce); return(nce); }