Ejemplo n.º 1
0
        public async Task <bool> CreateBuildingActivity(BuildingActivity buildingActivity)
        {
            _context.Add(buildingActivity);
            var res = await _context.SaveChangesAsync();

            return(res > 0);
        }
Ejemplo n.º 2
0
        public void BuildingActivity()
        {
            int count = uow.BuildingActivities.GetAll().AsQueryable<BuildingActivity>().Count<BuildingActivity>();

            #region Add

            BuildingActivity newEntity = new BuildingActivity()
            {
                BuildingActivityName = "BuildingActivityName",
                BuildingUsageID = (int)LookUps.LookUpsValues["BuildingUsageID"],
                MainBuildingActivityID = (int)LookUps.LookUpsValues["MainBuildingActivityID"]
            };
            uow.BuildingActivities.Add<BuildingActivity, int>(newEntity);
            uow.BuildingActivities.Commit();
            var result = uow.BuildingActivities.GetAll().AsQueryable<BuildingActivity>();
            Assert.AreEqual(count + 1, result.Count<BuildingActivity>(), "Adding Error");

            #endregion

            #region Update

            BuildingActivity entity = uow.BuildingActivities.GetById(newEntity.ID);
            entity.BuildingActivityName = "BuildingActivityName2";
            uow.BuildingActivities.Update(entity);
            uow.BuildingActivities.Commit();
            BuildingActivity entity2 = uow.BuildingActivities.GetById(newEntity.ID);
            Assert.AreEqual("BuildingActivityName2", entity2.BuildingActivityName, "Updating Error");

            #endregion

            #region Delete

            BuildingActivity entityDeleted = uow.BuildingActivities.GetById(newEntity.ID);
            uow.BuildingActivities.Delete(entity2);
            uow.BuildingActivities.Commit();
            Assert.AreEqual(count, uow.BuildingActivities.GetAll().AsQueryable<BuildingActivity>().Count<BuildingActivity>(), "Deleting Error");

            #endregion
        }
Ejemplo n.º 3
0
 static int BuildingActivity()
 {
     BuildingActivity e = new BuildingActivity()
     {
         BuildingActivityName = "BuildingActivityName",
         BuildingUsageID = (int)LookUpsValues["BuildingUsageID"],
         MainBuildingActivityID = (int)LookUpsValues["MainBuildingActivityID"]
     };
     technicalLicensesUow.BuildingActivities.Add<BuildingActivity, int>(e);
     technicalLicensesUow.BuildingActivities.Commit();
     return e.ID;
 }