Exemplo n.º 1
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(Event_EN event_)
        {
            try
            {
                SessionInitializeTransaction();
                Event_EN event_EN = (Event_EN)session.Load(typeof(Event_EN), event_.Id);



                event_EN.Date = event_.Date;

                session.Update(event_EN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in Event_CAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 2
0
        public Event_EN ReadOIDDefault(int id
                                       )
        {
            Event_EN event_EN = null;

            try
            {
                SessionInitializeTransaction();
                event_EN = (Event_EN)session.Get(typeof(Event_EN), id);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in Event_CAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(event_EN);
        }
Exemplo n.º 3
0
        public void DeleteEvent(int id
                                )
        {
            try
            {
                SessionInitializeTransaction();
                Event_EN event_EN = (Event_EN)session.Load(typeof(Event_EN), id);
                session.Delete(event_EN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in Event_CAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 4
0
        public int NewEvent(Event_EN event_)
        {
            try
            {
                SessionInitializeTransaction();

                session.Save(event_);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in Event_CAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(event_.Id);
        }
Exemplo n.º 5
0
        public Event_EN ReadOID(int id
                                )
        {
            Event_EN event_EN = null;

            event_EN = _IEvent_CAD.ReadOID(id);
            return(event_EN);
        }
Exemplo n.º 6
0
        public void ModifyEvent(int p_Event_OID, Nullable <DateTime> p_date)
        {
            Event_EN event_EN = null;

            //Initialized Event_EN
            event_EN      = new Event_EN();
            event_EN.Id   = p_Event_OID;
            event_EN.Date = p_date;
            //Call to Event_CAD

            _IEvent_CAD.ModifyEvent(event_EN);
        }
Exemplo n.º 7
0
        public int NewEvent(Nullable <DateTime> p_date)
        {
            Event_EN event_EN = null;
            int      oid;

            //Initialized Event_EN
            event_EN      = new Event_EN();
            event_EN.Date = p_date;

            //Call to Event_CAD

            oid = _IEvent_CAD.NewEvent(event_EN);
            return(oid);
        }
Exemplo n.º 8
0
        public void PublishPostOkTest()
        {

            //Create mocks
            var postCADMock = new Mock<IPostCAD>();
            var pickCADMock = new Mock<IPickCAD>();

            //Prepare data to be returned by mocks
            List<int> pick_ids = new List<int>();
            pick_ids.Add(1);
            PickEN pick = new PickEN();
            Event_EN eventPick = new Event_EN();
            eventPick.Date = new DateTime(2018, 1, 16, 15, 0, 0);
            pick.Event_rel = eventPick;
            List<PickEN> picks = new List<PickEN>();
            picks.Add(pick);
            PostEN expectedPost = new PostEN();
            expectedPost.Pick = picks;

            //Setup mock methods
            postCADMock.Setup(mock => mock.NewPost(It.IsAny<PostEN>())).Returns(1);
            postCADMock.Setup(mock => mock.GetByID(It.IsAny<int>())).Returns(expectedPost);
            pickCADMock.Setup(mock => mock.GetByID(It.IsAny<int>())).Returns(pick);

            PostCEN postCEN = new PostCEN(postCADMock.Object);
            PickCEN pickCEN = new PickCEN(pickCADMock.Object);

            PostEN actualPost = postCEN.PublishPost(It.IsAny<TimeSpan>(), It.IsAny<TimeSpan>(), It.IsAny<Double>(), It.IsAny<string>(), It.IsAny<bool>(), pick_ids, It.IsAny<int>(), It.IsAny<double>(), It.IsAny<PickResultEnum>(), pickCEN);

            //Test method (check if picks are equal)
            Assert.AreEqual(expectedPost.Pick, actualPost.Pick);
            Assert.IsNotNull(expectedPost);

            //Verify mocks
            postCADMock.Verify(mock => mock.NewPost(It.IsAny<PostEN>()), Times.Once);
            postCADMock.Verify(mock => mock.GetByID(It.IsAny<int>()), Times.Once);
            pickCADMock.Verify(mock => mock.GetByID(It.IsAny<int>()), Times.AtLeastOnce);

        }