示例#1
0
        public void Delete()
        {
            var gameBusiness = new GameBusiness();

            var result = gameBusiness.Delete(2);

            Assert.IsNotNull(result);

            result = gameBusiness.Delete(-1);

            Assert.IsNull(result);
        }
示例#2
0
        public HttpResponseMessage Delete(int id)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError);

            try
            {
                GameBusiness gameBusiness = new GameBusiness();

                var result = gameBusiness.Delete(id);

                if (result != null)
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, "Game successfully deleted");
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound, "Game not found");
                }
            }
            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;
 }