public void saveEvent(entities.Event evento)
 {
     using (var db = new MedellinTimesContext())
     {
         try
         {
             db.Event.Add(evento);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             var error = e.Message;
         }
     }
 }
        public void getEventById(Guid id)
        {
            var eventtest = new entities.Event();

            eventtest.Id = Guid.Parse("D6E90323-51B0-45C9-ACA4-DE755F44642B");
            // Set up Prerequisites
            var controller = new api.EventsController();
            // Act on Test
            var response      = controller.GetEvent("D6E90323-51B0-45C9-ACA4-DE755F44642B");
            var contentResult = response as OkNegotiatedContentResult <entities.Event>;

            // Assert the result
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(eventtest.Id, contentResult.Content.Id);
        }
        public void AddEvent()
        {
            // Arrange
            var controller = new  api.EventsController();

            entities.Event evento = new entities.Event {
                Id   = Guid.NewGuid(),
                Name = "evento1", Description = "descrip", Adress = "sfsff", DateEvent = DateTime.Now
            };
            // Act
            IHttpActionResult actionResult = controller.PostEvent(evento);
            var createdResult = actionResult as OkNegotiatedContentResult <entities.Event>;

            // Assert
            Assert.IsNotNull(createdResult);
            Assert.AreEqual(evento.Id, createdResult.Content.Id);
        }
        public void AddEvent_shouldNotSave()
        {
            // Arrange
            var controller = new api.EventsController();

            entities.Event evento = new entities.Event
            {
                Name        = "evento1",
                Description = "descrip",
                Adress      = "sfsff",
            };
            // Act
            IHttpActionResult actionResult = controller.PostEvent(evento);
            var createdResult = actionResult as OkNegotiatedContentResult <InvalidModelStateResult>;

            // Assert
            Assert.IsNotNull(createdResult);
            Assert.IsInstanceOfType(createdResult.Content, typeof(InvalidModelStateResult));
        }
        public async Task <bool> updateEvent(entities.Event evento)
        {
            var isupdtae = false;

            using (var db = new MedellinTimesContext())
            {
                try
                {
                    /*  var updateEvent = await db.Event.FirstAsync(e => e.Id == evento.Id);
                     * updateEvent.Name = evento.Name;
                     * updateEvent.Description = evento.Description;
                     * updateEvent.Adress = evento.Adress;
                     */
                    db.Entry(evento).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(isupdtae = true);
                }
                catch (Exception e)
                {
                    return(isupdtae = false);
                }
            }
        }