Exemplo n.º 1
0
        public IHttpActionResult Delete(string id)
        {
            try
            {
                ProblemViewModel vm = new ProblemViewModel();
                vm.ProblemId = id;
                vm.GetById();
                long retVal = vm.Delete();
                switch (retVal)
                {
                case 1:
                    return(Ok("Problem deleted!"));

                case 0:
                    return(Ok("Problem not deleted!"));

                default:
                    return(Ok("Problem not deleted!"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Retrieve failed - " + ex.Message));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult Delete(string id)
        {
            try
            {
                ProblemViewModel prob = new ProblemViewModel();
                prob.Id = id;
                long delRetVal = prob.Delete();

                switch (delRetVal)
                {
                case 1:
                    return(Ok("Ok! Problem " + prob.Description + " has been Deleted!"));

                case 0:
                    return(Ok("Error! Problem does not Exist!"));

                default:
                    return(Ok("Problem " + prob.Description + " not deleted!"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Delete Failed - Contact Tech Support"));
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult Delete(ProblemViewModel prob)
        {
            string msg = prob.Description + " has been deleted";

            try
            {
                prob.Delete();
                return(Ok(msg));
            }
            catch (Exception ex)
            {
                return(BadRequest("Delete failed - " + ex.Message));
            }
        }
Exemplo n.º 4
0
    public void TestDeleteShouldReturnOne()
    {
        if (!did_create_run)
        {
            TestCreateShouldReturnNewId();
        }

        ProblemViewModel vm = new ProblemViewModel();

        vm.ProblemId = id_string;
        vm.GetById();

        Assert.IsTrue(vm.Delete() == 1);
    } // TestDeleteShouldReturnOne
Exemplo n.º 5
0
 public IHttpActionResult Delete(string Id)
 {
     try
     {
         ProblemViewModel prob = new ProblemViewModel();
         prob.Id = Id;
         prob.GetByID(Id);
         prob.Delete();
         return(Ok("Problem deleted!"));
     }
     catch (Exception ex)
     {
         return(BadRequest("Update failed - " + ex.Message));
     }
 }
Exemplo n.º 6
0
        public void ProblemVMCreateAndDeleteShouldReturnTrue()
        {
            bool             deleteOk = false;
            ProblemViewModel vm       = new ProblemViewModel();

            // and some hardcoded data
            vm.Description = "some Description";
            vm.Create();

            if (vm.Id.Length == 24) //new id's are a 24 byte hex string
            {
                deleteOk = vm.Delete();
            }
            Assert.IsTrue(deleteOk);
        }