/// <summary> /// Gets the showpage based on the show id and values tied to the user /// </summary> /// <param name="id">Show ID</param> /// <returns>showpage view</returns> public ActionResult ShowPage(int?id) { //check for null id if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Show show = showRep.GetByID(id.Value); ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); List <string> Statuses = new List <string>(); Statuses.Add("Watching"); Statuses.Add("Completed"); Statuses.Add("On-Hold"); Statuses.Add("Plan to Watch"); ViewBag.sl = new SelectList(Statuses); //Check if show exists in usershow based on the current user UserShow usershow = userShowRep.GetByID(User.Identity.GetUserId(), id.Value); //If show does not exist in usershow, then set it as a new usershow for the user if (usershow == null) { usershow = new UserShow { ShowID = id.Value, CurrentEp = 0, Show = show, ShowName = show.Name, Status = "Status", TotalEp = show.TotalEp, User = user, UserID = User.Identity.GetUserId() }; } return(View(usershow)); }
public ActionResult ShowPage(ShowPageViewModel showpageviewmodel) { ApplicationUser user = UserManager.FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); UserShow usershow = userShowRep.GetByID(User.Identity.GetUserId(), showpageviewmodel.ShowID); List <string> Statuses = new List <string>(); Statuses.Add("Watching"); Statuses.Add("Completed"); Statuses.Add("On-Hold"); Statuses.Add("Plan to Watch"); ViewBag.sl = new SelectList(Statuses); //If current show did not exist in usershow table if (usershow == null) { // add usershow to table usershow = new UserShow { ShowID = showpageviewmodel.ShowID, CurrentEp = showpageviewmodel.CurrentEp, ShowName = showpageviewmodel.ShowName, Status = showpageviewmodel.Status, TotalEp = showpageviewmodel.TotalEp, UserID = User.Identity.GetUserId() }; // if its valid, the save the table if (ModelState.IsValid) { userShowRep.InsertObj(usershow); userShowRep.Save(); } } //if the usershow exists in the usershow table else { //Check for delete button press if (showpageviewmodel.CurrentEp == -1) { userShowRep.DeleteObj(user.Id, showpageviewmodel.ShowID); userShowRep.Save(); return(Redirect(Request.UrlReferrer.ToString())); } //check for update button press else { usershow.CurrentEp = showpageviewmodel.CurrentEp; usershow.Status = showpageviewmodel.Status; if (ModelState.IsValid) { userShowRep.UpdateObj(usershow); userShowRep.Save(); } } } //returns usershow and reload the page usershow.Show = showRep.GetByID(showpageviewmodel.ShowID); usershow.User = user; return(View(usershow)); }
// GET: ShowEpisodes/Details/5 public ActionResult Details(UserShow userShow) { if (userShow == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(View(userShow)); }
public async Task <ActionResult> UpdateUserShow(int userId, int showId, [FromBody] UserShow userShow) { if (userId != userShow.UserId || showId != userShow.ShowId) { return(BadRequest()); } await _userShowsRepository.UpdateUserShow(userShow); return(NoContent()); }
private void cb_user_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cb_user.SelectedIndex == 1) { UserShow us = new UserShow(borrowuser); us.ShowDialog(); } if (cb_user.SelectedIndex == 2) { WrenchBorrowHistory wbh = new WrenchBorrowHistory(); List <BorrowHistory> bhl = wbh.GetByUser(Borrow.SelectByUser(SystData.userInfo.user.guid)); UserBorrow ub = new UserBorrow(bhl); ub.ShowDialog(); } this.cb_user.SelectedIndex = 0; }
public IActionResult unJoin(int ShowId, int UserId) { User user = dbContext.Users .FirstOrDefault(u => u.UserId == UserId); Show show = dbContext.Shows .FirstOrDefault(s => s.ShowId == ShowId); UserShow userShow = dbContext.UserShows .Where(us => us.ShowId == ShowId && us.UserId == UserId) .FirstOrDefault(); dbContext.UserShows.Remove(userShow); dbContext.SaveChanges(); return(RedirectToAction("ViewShow", new{ ShowId = ShowId })); }
public IActionResult JoinEvent(int ShowId, int UserId) { System.Console.WriteLine("*******************"); if (HttpContext.Session.GetInt32("InSession") != null) { System.Console.WriteLine("&&&&&&&&&&&&&&&&&&&&&&&&&"); UserShow userShow = new UserShow(); userShow.UserId = UserId; userShow.ShowId = ShowId; dbContext.UserShows.Add(userShow); dbContext.SaveChanges(); System.Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@"); return(RedirectToAction("UpcomingShows")); } return(RedirectToAction("Index")); }
public ActionResult Show(int id) { if (Session["ID"] == null) { return(View("Error")); } var model = new UserShow(); var client = new RestClient(ConfigurationManager.AppSettings.Get("APIURL")); var request = new RestRequest($"user/{id}", Method.GET); var request2 = new RestRequest($"skill", Method.GET); var content = client.Execute(request); var content2 = client.Execute(request2); model.User = JsonConvert.DeserializeObject <User>(content.Content); model.Skills = JsonConvert.DeserializeObject <List <Skill> >(content2.Content); var storageLocation = $"/Content/Uploads/Users/{id}/"; if (model.User.ProfilePicture != null) { model.User.ProfilePicture = storageLocation + model.User.ProfilePicture; } var fileController = new FileController(); model.Images = fileController.GetImages(model.User.Files); for (var i = 0; i < model.Images.Count; ++i) { model.Images[i].Name = storageLocation + model.Images[i].Name; } model.Music = fileController.GetMusic(model.User.Files); for (var i = 0; i < model.Music.Count; ++i) { model.Music[i].Name = storageLocation + model.Music[i].Name; } return(View(model)); }
/// <summary> /// Show/Hide comment in demostration </summary> /// <param name="subtaskId">Comment ID</param> /// <param name="userDto">user DTO</param> /// <returns>Value of flag</returns> public bool InvertCommentShow(Guid commentId, UserDto userDto) { var rep = UnitOfWork.GetRepository <UserShow>(); var model = rep.SearchFor(e => e.UserId == userDto.Id && e.CommentId == commentId).FirstOrDefault(); if (model != null) { rep.DeleteById(model.EntityId); this.UnitOfWork.SaveChanges(); return(false); } else { model = new UserShow(); model.UserId = userDto.Id; model.CommentId = commentId; rep.Insert(model, userDto.Id); this.UnitOfWork.SaveChanges(); return(true); } }
public async Task <ObjectResult> FullInformation(string id) { WebReq req = new WebReq(); UserList dBUserItemsDBFind = JsonConvert.DeserializeObject <UserList>(System.IO.File.ReadAllText(path)); Commands comm = new Commands(); comm.DBCheck(comm, dBUserItemsDBFind, id); if (comm.Exist == false) { Response.StatusCode = 404; return(new ObjectResult(null)); } if (dBUserItemsDBFind == null) { Response.StatusCode = 404; } string real = dBUserItemsDBFind.users[comm.Index].Real; //List<string> cryptos = new List<string>(); UserShow userShow = await req.GetTickers(dBUserItemsDBFind, comm.Index, real); return(new ObjectResult(userShow.Ticker)); }
public async Task UpdateUserShow(UserShow userShow) { _context.UserShows.Update(userShow); await _context.SaveChangesAsync(); }
public async Task AddUserShow(UserShow userShow) { _context.UserShows.Add(userShow); await _context.SaveChangesAsync(); }
public async Task <ObjectResult> Information(string id, string cryptoname) { WebReq req = new WebReq(); UserList dBUserItemsDBFind = JsonConvert.DeserializeObject <UserList>(System.IO.File.ReadAllText(path)); Commands comm = new Commands(); comm.DBCheck(comm, dBUserItemsDBFind, id); if (comm.Exist == false) { Response.StatusCode = 404; return(new ObjectResult(null)); } if (dBUserItemsDBFind == null) { Response.StatusCode = 404; } client = new CoinpaprikaAPI.Client(); var coins = await client.GetCoinsAsync(); string s = JsonConvert.SerializeObject(coins); Value st = JsonConvert.DeserializeObject <Value>(s); Dictionary <string, string> names = new Dictionary <string, string>(); int lenght = st.value.Count; for (int i = 0; i < lenght; i++) { st.value[i].Name = st.value[i].Name.ToLower(); names.Add(st.value[i].Id, st.value[i].Name); } string temp2 = names.FirstOrDefault(x => x.Value == cryptoname).Key; if (temp2 == null) { Response.StatusCode = 404; return(new ObjectResult(null)); } string real = dBUserItemsDBFind.users[comm.Index].Real; List <string> cryptos = new List <string>(); UserShow userShow = await req.GetTickers(dBUserItemsDBFind, comm.Index, real); int cryind = 0; bool exist = false; for (int i = 0; i < userShow.Ticker.Count; i++) { string t = userShow.Ticker[i].Name.ToLower(); if (t == cryptoname) { cryind = i; exist = true; } } if (exist == true) { return(new ObjectResult(userShow.Ticker[cryind])); } else { Response.StatusCode = 404; return(new ObjectResult(null)); } }
public async Task <ActionResult <UserShow> > AddUserShow(UserShow userShow) { await _userShowsRepository.AddUserShow(userShow); return(CreatedAtAction("AddUserShow", new { userId = userShow.UserId, showId = userShow.ShowId }, userShow)); }