public ActionResult PostDlc(string username, [FromBody] int id) { UserDlc userDlc; try { User user = Repo.GetUser(username); Dlc dlc = Repo.GetDlc(id); if (user == null || dlc == null) { return(StatusCode(400)); } userDlc = new UserDlc { User = user, Dlc = dlc }; bool check = Repo.AddUserDlc(userDlc); //check is for checking if the username already exists, and if it does return status code 409 if (!check) { return(StatusCode(409)); } } catch (Exception) { return(StatusCode(500)); } return(CreatedAtRoute("GetUserDlc", new { username = userDlc.User.UserName, id = userDlc.Dlc.Dlcid }, userDlc)); }
void TestIsReady(int errorCode) { if (errorCode == SUCCESS) { TestLogger.Success("IsReady", "IsReady success."); var dlcCount = Dlc.GetCount(); TestLogger.Success("GetCount", dlcCount.ToString()); for (var i = 0; i < dlcCount; i++) { var viveporId = string.Empty; var isAvailable = false; bool isNotOverRange = Dlc.GetIsAvailable(i, out viveporId, out isAvailable); if (isNotOverRange) { TestLogger.Success("GetIsAvailable", string.Format("VIVEPORT ID: {0}, Is Available: {1}", viveporId, isAvailable)); } else { TestLogger.Error("GetIsAvailable", "Index is out of range."); break; } } } else { TestLogger.Error("IsReady", string.Format("IsReady failure. Error Code: {0}", errorCode)); } Api.Shutdown(TestShutdownCallback); }
public ActionResult Put(int id, [FromBody] Dlc value) { Dlc dlc; try { dlc = Repo.GetDlc(id); } catch (Exception ex) { return(StatusCode(500)); } if (dlc == null) { return(NotFound()); } if (dlc.Dlcid != value.Dlcid) { return(BadRequest("cannot change ID")); } try { Repo.UpdateDlc(value); } catch (Exception ex) { // internal server error return(StatusCode(500)); } return(NoContent()); }
public async Task <ActionResult> Create(FullDlc fulldlc) { Dlc dlc = fulldlc.Dlc; try { HttpRequestMessage request = CreateRequest(HttpMethod.Post, "api/Dlc", dlc); HttpResponseMessage response = await Client.SendAsync(request); if (!response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.Unauthorized) { return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Error", "Home")); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Edit([Bind(Include = "IdDlc,NomeDlc,DescricaoDlc,PrecoDlc,IdJogo")] DlcViewModel viewModel) { if (ModelState.IsValid) { Dlc dlc = Mapper.Map <DlcViewModel, Dlc>(viewModel); repositorioDlc.Alterar(dlc); return(RedirectToAction("Index")); } //ViewBag.IdJogo = new SelectList(db.Jogo, "Id", "Nome", dlc.IdJogo); return(View(viewModel)); }
public DlcViewModel(Dlc dlc) { Id = dlc.Id; ParentGameId = dlc.ParentGameId; Name = dlc.Name; Owned = dlc.Owned; Price = dlc.Price; Notes = dlc.Notes; Rating = dlc.Rating; Ranking = dlc.Ranking; Store = dlc.Store; }
public void AddFavorite(Dlc dlc) { lock (FavoriteDlcs) { if (FavoriteDlcs.Any(f => f.Matches(dlc))) { return; } FavoriteDlcs.Add(new FavoriteDlc(dlc)); } SaveSettings(); }
void TestInitCallback(int errorCode) { if (errorCode == SUCCESS) { TestLogger.Success("Init", "Init success."); Dlc.IsReady(TestIsReady); } else { TestLogger.Error("Init", string.Format("Init failure. Error Code: {0}", errorCode)); } }
public void RemoveFavorite(Dlc dlc) { lock (FavoriteDlcs) { var favorite = FavoriteDlcs.FirstOrDefault(f => f.Matches(dlc)); if (favorite == null) { return; } FavoriteDlcs.Remove(favorite); } SaveSettings(); }
// GET: Dlcs/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dlc dlc = repositorioDlc.SelecionarPorId((int)id.Value); if (dlc == null) { return(HttpNotFound()); } return(View(Mapper.Map <Dlc, DlcIndexViewModel>(dlc))); }
public static void GenerateFilter(Dlc dlc, int amountTracks, int amountCars) { Random rdm = new Random(); string input; List <Car> _modifiedCars = new List <Car>(); //Filter lists foreach (Car car in _cars) { if (!car.IsDlc) { continue; } if (car.DlcPack == dlc) { _modifiedCars.Add(car); } } do { string strCar; StringBuilder strCircuit = new StringBuilder(); for (int i = 0; i < amountCars; i++) { int rdmCar = rdm.Next(_modifiedCars.Count - 1); strCar = $"Car{i + 1}: {_modifiedCars[rdmCar].Brand} {_modifiedCars[rdmCar].Model} {_modifiedCars[rdmCar].Year}"; if (_modifiedCars[rdmCar].IsDlc) { strCar += _modifiedCars[rdmCar].DlcPack; } strCar += "\n"; } } while (input != null && input.ToLower() != "n"); string strCar = ""; StringBuilder strCircuit = new StringBuilder(); for (int i = 0; i < amountCars; i++) { } }
public ActionResult Post([FromBody] Dlc dlc) { try { bool check = Repo.AddDlc(dlc); //check is for checking if the username already exists, and if it does return status code 409 if (!check) { return(StatusCode(409)); } } catch (Exception) { return(StatusCode(500)); } return(CreatedAtRoute("GetDlc", new { id = dlc.Dlcid }, dlc)); }
// GET: Dlcs/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dlc dlc = repositorioDlc.SelecionarPorId((int)id.Value); if (dlc == null) { return(HttpNotFound()); } //ViewBag.IdJogo = new SelectList(db.Jogo, "Id", "Nome", dlc.IdJogo); List <JogoIndexViewModel> jogos = Mapper.Map <List <Jogo>, List <JogoIndexViewModel> >(repositorioJogo.Selecionar()); SelectList dropDownJogos = new SelectList(jogos, "Id", "Nome"); ViewBag.DropDownJogos = dropDownJogos; return(View(Mapper.Map <Dlc, DlcViewModel>(dlc))); }
public async Task <ActionResult> Edit(int id, Dlc dlc) { try { HttpRequestMessage request = CreateRequest(HttpMethod.Put, $"api/Dlc/{id}", dlc); HttpResponseMessage response = await Client.SendAsync(request); if (!response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.Unauthorized) { return(RedirectToAction("Login", "Account")); } return(View()); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
// GET: UserDlc/Create public async Task <ActionResult> Purchase(int id) { string username = ViewBag.LoggedInUser; if (username == "") { return(RedirectToAction("Login", "Account")); } HttpRequestMessage request = CreateRequest(HttpMethod.Get, $"api/Dlc/{id}"); HttpRequestMessage request2 = CreateRequest(HttpMethod.Get, $"api/User/{username}"); HttpResponseMessage response = await Client.SendAsync(request); HttpResponseMessage response2 = await Client.SendAsync(request2); if (!response.IsSuccessStatusCode || !response2.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.Unauthorized || response2.StatusCode == HttpStatusCode.Unauthorized) { return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Error", "Home")); } string resString = await response.Content.ReadAsStringAsync(); string resString2 = await response2.Content.ReadAsStringAsync(); Dlc dlc = JsonConvert.DeserializeObject <Dlc>(resString); User user = JsonConvert.DeserializeObject <User>(resString2); return(View(new UserDlc { Dlc = dlc, User = user })); }
public bool IsFavorite(Dlc dlc) { return FavoriteDlcs.Any(f => f.Matches(dlc)); }
public FavoriteDlc(Dlc dlc) { _Uuid = dlc.Id; }
public void AddFavorite(Dlc dlc) { lock (FavoriteDlcs) { if (FavoriteDlcs.Any(f => f.Matches(dlc))) return; FavoriteDlcs.Add(new FavoriteDlc(dlc)); } SaveSettings(); }
public bool IsFavorite(Dlc dlc) => FavoriteDlcs.Any(f => f.Matches(dlc));
void AfterDlcDataModelMap(Dlc src, DlcDataModel dest) { Map(src.MetaData, dest); }
public void RemoveFavorite(Dlc dlc) { lock (FavoriteDlcs) { var favorite = FavoriteDlcs.FirstOrDefault(f => f.Matches(dlc)); if (favorite == null) return; FavoriteDlcs.Remove(favorite); } SaveSettings(); }
InstalledDlc CreateInstalledDlc(Dlc dlc) => new InstalledDlc { Id = dlc.Id };
public bool Matches(Dlc dlc) => dlc != null && dlc.Id == _Uuid;
InstalledDlc CreateInstalledDlc(Dlc dlc) { return new InstalledDlc {Id = dlc.Id}; }
public static string GetTitle(this Dlc dlc) { return(nameList[(int)dlc]); }
public bool Matches(Dlc dlc) { return dlc != null && dlc.Id == _Uuid; }
private void CreateDlcPack(string savePath) { Dlc.Create(dlcType, dlcName, savePath); }