public void Create()
 {
     try
     {
         Problem prb = new Problem();
         prb.Description = Description;
         Id = _dao.Create(prb);
     } catch (Exception ex)
     {
         ErrorRoutine(ex, "ProblemViewModel", "Create");
     }
 }
        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);
        }
示例#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;
        }
示例#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;
        }
示例#5
0
 private void InsertProblem(string description)
 {
     Problem prb = new Problem();
     prb.Description = description;
     ctx.Save<Problem>(prb, "problems");
 }