public Talks Update(Talks talkToUpdate) { var updatedTalk = conferenceContext.Update(talkToUpdate); conferenceContext.SaveChanges(); return(updatedTalk.Entity); }
public async Task <IActionResult> Edit(Talks talks) { if (talks.Id == 0) { return(NotFound()); } var talksFromDb = await _db.Talks.Where(c => c.Id == talks.Id).FirstOrDefaultAsync(); if (ModelState.IsValid) { var files = HttpContext.Request.Form.Files; if (files.Count > 0) { byte[] p1 = null; using (var fs1 = files[0].OpenReadStream()) { using (var ms1 = new MemoryStream()) { fs1.CopyTo(ms1); p1 = ms1.ToArray(); } } talksFromDb.Picture = p1; } talksFromDb.Name = talks.Name; talksFromDb.Description = talks.Description; talksFromDb.Date = talks.Date; talksFromDb.IsActive = talks.IsActive; await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(talks)); }
public void CreateTest() { String stalkId = "4"; int talkId = 20; int UserInfoId = 5645; string msg = String.Empty; if (String.IsNullOrEmpty(stalkId)) { msg = "fail"; } if (FavorsService.GetEntities(u => u.TalkID == talkId && u.UserInfoID == UserInfoId).Count() > 0) { msg = "fail"; } Favors favors = new Favors() { UserInfoID = UserInfoId, TalkID = talkId, CreateTime = DateTime.Now, ModfiedOn = DateTime.Now, Status = (short)Model.Enum.DelFlagEnum.Normal, }; Talks talks = TalksService.GetEntities(u => u.TalkID == talkId).FirstOrDefault(); talks.TalkFavorsNum = talks.TalkFavorsNum + 1; if (FavorsService.Add(favors) != null && TalksService.Update(talks)) { msg = "success"; } msg = "fail"; }
/// <summary> /// Setup the talks /// </summary> /// <param name="talks"></param> private void SetTalks(DataModel.Interfaces.ITalk[] talks) { Talks.MakeListLookLike(talks, (oItem, dItem) => oItem.Talk.Equals(dItem), dItem => new TalkUserControlViewModel(dItem) ); }
public async Task <IActionResult> Create(Talks talks) { if (ModelState.IsValid) { var files = HttpContext.Request.Form.Files; if (files.Count > 0) { byte[] p1 = null; using (var fs1 = files[0].OpenReadStream()) { using (var ms1 = new MemoryStream()) { fs1.CopyTo(ms1); p1 = ms1.ToArray(); } } talks.Picture = p1; } _db.Talks.Add(talks); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(talks)); }
public Talks Update(Talks talks) { var update = conferenceContext.Talks.Update(talks); conferenceContext.SaveChanges(); return(update.Entity); }
public ActionResult Create() { if (LoginUser == null) { return(Json(new { msg = "nologin" }, JsonRequestBehavior.AllowGet)); } int talkId = 0; if (String.IsNullOrEmpty(Request["talkId"])) { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } talkId = int.Parse(Request["talkId"]); if (FavorsService.GetEntities(u => u.TalkID == talkId && u.UserInfoID == LoginUser.UserInfoID).Count() > 0) { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } Favors favors = new Favors() { UserInfoID = LoginUser.UserInfoID, TalkID = talkId, CreateTime = DateTime.Now, ModfiedOn = DateTime.Now, Status = (short)Model.Enum.DelFlagEnum.Normal, }; Talks talks = TalksService.GetEntities(u => u.TalkID == talkId).FirstOrDefault(); talks.TalkFavorsNum = talks.TalkFavorsNum + 1; if (FavorsService.Add(favors) != null && TalksService.Update(talks)) { return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet)); } return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,MeetingId,NameSpeaker,Topic")] Talks talks) { if (id != talks.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(talks); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TalksExists(talks.Id)) { return(NotFound()); } else { throw; } } //return RedirectToAction(nameof(Index)); return(RedirectToAction("EditSpeakers", "Meetings", new { id = talks.MeetingId })); } return(View(talks)); }
public Task <TalkSummary[]> GetTalkSummaries(int page) { var actualPage = Math.Max(0, page - 1); return(Task.FromResult(Talks.Skip(actualPage * Constants.PageSize).Take(Constants.PageSize) .Select(MapTalkToSummary).ToArray())); }
public Talks AddTalk(Talks talkToBeAdded) { var addedTalk = conferenceContext.Add(talkToBeAdded); conferenceContext.SaveChanges(); return(addedTalk.Entity); }
public Talks CreateTalk(Talks talks) { var create = conferenceContext.Talks.Add(talks); conferenceContext.SaveChanges(); return(create.Entity); }
// GET: Talks/Details/5 public ActionResult Details(int id) { Talks talk = talkService.GetTalkById(id); TalksViewModel model = new TalksViewModel(); model.InjectFrom(talk); return(View(talk)); }
public Talks CreateATalk(Talks talks) { if (IsUnique(talks.Name)) { return(talksRepository.CreateATalk(talks)); } return(null); }
public async Task <TalkDetail> GetTalkDetail(string id) { var detail = Talks.Select(MapTalkToDetail).FirstOrDefault(t => t.Id == id); detail.SpeakerTalks = await GetOtherTalksBySpeaker(id); return(detail); }
private Task <TalkSummary[]> GetOtherTalksBySpeaker(string id) { var talk = Talks.FirstOrDefault(t => t.Id == id); var talks = Talks.Where(t => t.Id != id && t.Speaker == talk.Speaker) .Take(10).Select(MapTalkToSummary).ToArray(); return(Task.FromResult(talks)); }
public Task <Talk> UpdateTalk(string id, UpdatedTalk talk, string version) { var oldTalk = Talks.FirstOrDefault(t => t.Id == id); oldTalk.Headline = talk.Headline; oldTalk.Description = talk.Description; return(Task.FromResult(oldTalk)); }
public Task <TalkSummary[]> GetTalksBySpeaker(string speaker, int show) { var actualPage = Math.Max(0, show - 1); var talks = Talks.Where(t => t.Speaker == speaker) .Skip(actualPage * Constants.PageSize).Take(Constants.PageSize) .Select(MapTalkToSummary).ToArray(); return(Task.FromResult(talks)); }
public Task <TalkSummary[]> GetTalksByTag(string tag, int show) { var actualPage = Math.Max(0, show - 1); var talks = Talks.Where(t => t.Tags.Contains(tag)) .Skip(actualPage * Constants.PageSize).Take(Constants.PageSize) .Select(MapTalkToSummary).ToArray(); return(Task.FromResult(talks)); }
public ActionResult Edit(int id, TalkViewModel model) { Talks edit = new Talks(); edit.InjectFrom(model); var createNewTalk = talk.Update(edit); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(int id, TalksViewModel model) { Talks talk = new Talks(); talk.InjectFrom(model); var talkToUpdate = talkService.UpdateTalk(talk); return(RedirectToAction(nameof(Index))); }
void CheckEsc() { if (Input.GetKeyDown(KeyCode.Escape)) { ShowHideMenu(inMenu, !inMenu); DeleteEmptyDrops(); Talks.GetComponent <TalkMovement>().Exit(); } }
public override string ToString() { var sb = new StringBuilder(); foreach (var talk in Talks.OrderBy(x => x.StarTime)) { sb.AppendFormat("{0} {1}", talk, Environment.NewLine); } return(sb.ToString()); }
private DateTime GetStarTime() { if (!Talks.Any()) { return(startTime); } var lastTalk = Talks.OrderByDescending(x => x.StarTime).First(); return(lastTalk.StarTime.Value.AddMinutes(lastTalk.Duration)); }
public void AddTalk(Talk talk) { if (!CanAdd(talk)) { throw new NoSlotAvailableException(); } durationInMinute -= talk.Duration; talk.StarTime = GetStarTime(); Talks.Add(talk); }
public ActionResult Delete(int id, TalksViewModel model) { Talks talkToDelete = new Talks(); talkToDelete = talkService.GetTalkById(id); model.InjectFrom(talkToDelete); talkService.Delete(talkToDelete); talkService.Save(); return(RedirectToAction(nameof(Index))); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // Overflow is fine, just wrap unchecked { var hashCode = 41; // Suitable nullity checks etc, of course :) #pragma warning disable CA1307 // Specify StringComparison // ReSharper disable once NonReadonlyMemberInGetHashCode if (Id != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Id.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Name != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Name.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Venue != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Venue.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Speakers != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Speakers.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Talks != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Talks.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Friends != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Friends.GetHashCode(); } #pragma warning restore CA1307 // Specify StringComparison return(hashCode); } }
public Talks AddTalk(Talks talkToBeAdded) { if (IsUniqueTalk(talkToBeAdded.Name)) { return(talksRepository.AddTalk(talkToBeAdded)); } else { return(null); } }
public async Task <IActionResult> Create([Bind("MeetingId,NameSpeaker,Topic")] Talks talks) { if (ModelState.IsValid) { _context.Add(talks); await _context.SaveChangesAsync(); return(RedirectToAction("EditSpeakers", "Meetings", new { id = talks.MeetingId })); } return(View(talks)); }
public Task <TalkSummary[]> SearchTalks(string search, int page) { var actualPage = Math.Max(0, page - 1); var normalizedSearch = search.ToLowerInvariant(); var talks = Talks.Where(t => t.Headline.ToLowerInvariant().Contains(normalizedSearch) || t.Description.ToLowerInvariant().Contains(normalizedSearch)); return(Task.FromResult(talks.Skip(actualPage * Constants.PageSize).Take(Constants.PageSize) .Select(MapTalkToSummary).ToArray())); }
/// <summary> /// Adds the talk to this session. /// </summary> /// <param name="talk">The talk.</param> /// <exception cref="Shared.TrackManagementException">Unable to add talk to session.</exception> private void AddTalk(ITalk talk) { if (RemainingDuration <= 0 && BufferDuration <= 0) { throw new TrackManagementException(Resource.UnableToAddTalk); } SetTalkStartTime(talk); UpdateRemainingDuration(talk); Talks.Add(talk); UpdateNextSessionStartTime(talk.Duration); }
public Person(string name, Talks talks) { _name = name; _talks = talks; }