public ActionResult AddMark(int id)
 {
     logger.Debug("Starting Add Mark [Get] with : journalId {0}",id);
     var markModel = new JournalMarkModelDto();
     ViewBag.JournalId = id;
     return PartialView("_CreateMarkPartial", markModel);
 }
Exemplo n.º 2
0
        public ActionResult AddMark(int id)
        {
            logger.Debug("Starting Add Mark [Get] with : journalId {0}", id);
            var markModel = new JournalMarkModelDto();

            ViewBag.JournalId = id;
            return(PartialView("_CreateMarkPartial", markModel));
        }
        public ActionResult AddMark(int id,JournalMarkModelDto model)
        {
            if (ModelState.IsValid)
            {
                model.DateAdded = DateTime.Now;

                logger.Debug("Add Mark [Post] with : journalId {0} , model {1} ", id, model.ToString());
                if (_journalService.AddMark(id, model))
                {
                    logger.Debug("Add Mark [Post] - OK");
                    return RedirectToAction("Edit", new {id = id});
                }
                logger.Debug("Add Mark [Post] - Failed");
                return Json(new ResponseMessage(false));
            }
            logger.Debug("Add Mark [Post] - Model State Invalid");
            return Json(new ResponseMessage(false));
        }
Exemplo n.º 4
0
        public ActionResult AddMark(int id, JournalMarkModelDto model)
        {
            if (ModelState.IsValid)
            {
                model.DateAdded = DateTime.Now;

                logger.Debug("Add Mark [Post] with : journalId {0} , model {1} ", id, model.ToString());
                if (_journalService.AddMark(id, model))
                {
                    logger.Debug("Add Mark [Post] - OK");
                    return(RedirectToAction("Edit", new { id = id }));
                }
                logger.Debug("Add Mark [Post] - Failed");
                return(Json(new ResponseMessage(false)));
            }
            logger.Debug("Add Mark [Post] - Model State Invalid");
            return(Json(new ResponseMessage(false)));
        }
 public bool AddMark(int journalId, JournalMarkModelDto markDto)
 {
     try
     {
         Logger.Debug("AddMark - journal id : {0} , mark :  {1} ", journalId, markDto.Name);
         using(var session = DataAccess.OpenSession())
         {
             var journalModel = session.Get<JournalModel>(journalId);
             var mark = JournalMarkModelDto.UnMap(markDto);
             journalModel.Marks.Add(mark);
             session.Update(journalModel);
         }
         Logger.Debug("Journal : Mark Added");
         return true;
     }
     catch (Exception ex)
     {
         Logger.Error("Error : AddMark \r\n {0}", ex.Message);
         return false;
     }
 }
Exemplo n.º 6
0
 public bool AddMark(int journalId, JournalMarkModelDto markDto)
 {
     try
     {
         Logger.Debug("AddMark - journal id : {0} , mark :  {1} ", journalId, markDto.Name);
         using (var session = DataAccess.OpenSession())
         {
             var journalModel = session.Get <JournalModel>(journalId);
             var mark         = JournalMarkModelDto.UnMap(markDto);
             journalModel.Marks.Add(mark);
             session.Update(journalModel);
         }
         Logger.Debug("Journal : Mark Added");
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Error("Error : AddMark \r\n {0}", ex.Message);
         return(false);
     }
 }
        public void Can_add_mark()
        {
            #region Arrange
            var markDto = new JournalMarkModelDto{ Name="test mark", Value="0" };
            #endregion

            #region Act

            bool addOk = new JournalService().AddMark(1,markDto);

            using (var session = DataAccess.OpenSession())
            {
            var journal = session.Get<JournalModel>(1);

            #endregion

            #region Assert
            Assert.That(addOk, Is.True);
            Assert.That(journal.Marks.Count,Is.EqualTo(1));
            #endregion
            }
        }
        public void Can_add_mark()
        {
            #region Arrange
            var markDto = new JournalMarkModelDto {
                Name = "test mark", Value = "0"
            };
            #endregion

            #region Act

            bool addOk = new JournalService().AddMark(1, markDto);

            using (var session = DataAccess.OpenSession())
            {
                var journal = session.Get <JournalModel>(1);

                #endregion

                #region Assert
                Assert.That(addOk, Is.True);
                Assert.That(journal.Marks.Count, Is.EqualTo(1));
                #endregion
            }
        }