public void Create()
 {
     try
     {
         Problem prb = new Problem();
         prb.Description = Description;
         Id = _dao.Create(prb);
     } catch (Exception ex)
     {
         ErrorRoutine(ex, "ProblemViewModel", "Create");
     }
 }
Exemplo n.º 2
0
        public void ProblemDAOCreateAndDeleteShouldReturnTrue()
        {
            bool deleteOK = false;
            Problem prb = new Problem();
            ProblemDAO dao = new ProblemDAO();

            prb.Description = "It Broke";
            string newid = dao.Create(prb);

            if (newid.Length == 24)
                deleteOK = dao.Delete(newid);

            Assert.IsTrue(deleteOK);
        }
Exemplo n.º 3
0
        public string Create(Problem prb)
        {
            string newid = "";

            try
            {
                DbContext ctx = new DbContext();
                ctx.Save(prb, "problems");
                newid = prb._id.ToString();
            } catch (Exception ex)
            {
                DALUtils.ErrorRoutine(ex, "ProblemDAO", "Create");
            }

            return newid;
        }
Exemplo n.º 4
0
        public int Update(Problem prb)
        {
            int update = -1;
            try
            {
                DbContext ctx = new DbContext();
                ctx.Save<Problem>(prb, "problems");
                update = 1;
            }
            catch (MongoConcurrencyException ex)
            {
                update = -2;
            }
            catch (Exception ex)
            {
                DALUtils.ErrorRoutine(ex, "ProblemDAO", "Update:Error");
            }

            return update;
        }
Exemplo n.º 5
0
 private void InsertProblem(string description)
 {
     Problem prb = new Problem();
     prb.Description = description;
     ctx.Save<Problem>(prb, "problems");
 }