public void Update() { var gameBusiness = new GameBusiness(); var requestObject = new GameDTO() { Id = 1, Name = "Game_Updated" }; var result = gameBusiness.Update(requestObject); Assert.IsNotNull(result); Assert.AreEqual(1, result.Id); Assert.AreEqual("Game_Updated", result.Name); requestObject = new GameDTO() { Id = 500, Name = "Game_Updated" }; result = gameBusiness.Update(requestObject); Assert.IsNull(result); }
public HttpResponseMessage Put(GameDTO gameDTO) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError); try { if (ModelState.IsValid) { GameBusiness gameBusiness = new GameBusiness(); var result = gameBusiness.Update(gameDTO); if (result != null) { response = Request.CreateResponse(HttpStatusCode.OK, "Game successfully updated"); } else { response = Request.CreateResponse(HttpStatusCode.NotFound, "Game not found"); } } else { response = Request.CreateResponse(HttpStatusCode.BadRequest, "The request object doesn't match with the requirement"); } } catch (Exception e) { Logger.Error("GameController", "Get", e.Message); response = Request.CreateResponse(HttpStatusCode.InternalServerError, "Unexpected error"); } return response; }
private void btnSave_Click(object sender, EventArgs e) { if (btnDelete.Enabled == false && btnUpdate.Enabled == false) { game.Id = random.Next(4, 2147483647); game.Name = tb_name.Text; game.Description = txt_description.Text; game.Link = txt_link.Text; game.Date = txt_date.Text; game.Developer = txt_developer.Text; game.Genre = txt_genre.Text; game.Image = txt_image.Text; gameBusiness.Add(game); } else if (btnAdd.Enabled == false && btnUpdate.Enabled == false) { gameBusiness.Delete(tb_name.Text); } else { game.Id = random.Next(4, 2147483647); game.Name = tb_name.Text; game.Description = txt_description.Text; game.Link = txt_link.Text; game.Date = txt_date.Text; game.Developer = txt_developer.Text; game.Genre = txt_genre.Text; game.Image = txt_image.Text; gameBusiness.Update(game); } lb_description.Visible = true; txt_description.Visible = true; lb_link.Visible = true; txt_link.Visible = true; lb_date.Visible = true; txt_date.Visible = true; lb_developer.Visible = true; txt_developer.Visible = true; lb_genre.Visible = true; txt_genre.Visible = true; lb_image.Visible = true; txt_image.Visible = true; btnDelete.Enabled = true; btnAdd.Enabled = true; btnUpdate.Enabled = true; }