Пример #1
0
 public void SaveData(EntityCodeMap entityCodeMap)
 {
     using (var _nbdbContext = _contextFactory.CreateDbContext())
     {
         _nbdbContext.EntityCodeMaps.Add(entityCodeMap);
         _nbdbContext.SaveChanges();
     }
 }
Пример #2
0
 public EntityCodeMap UpdateData(EntityCodeMap entityCodeMap)
 {
     using (var _nbdbContext = _contextFactory.CreateDbContext())
     {
         _nbdbContext.EntityCodeMaps.Update(entityCodeMap);
         _nbdbContext.SaveChanges();
         return(entityCodeMap);
     }
 }
Пример #3
0
 public bool DeleteData(EntityCodeMap entityCodeMap)
 {
     using (var _nbdbContext = _contextFactory.CreateDbContext())
     {
         var mapToDelete = _nbdbContext.EntityCodeMaps.FirstOrDefault(x => x.Fund == entityCodeMap.Fund);
         _nbdbContext.EntityCodeMaps.Remove(mapToDelete);
         _nbdbContext.SaveChanges();
         return(true);
     }
 }
        public void Execute(string entitycode)
        {
            var map = _repository.GetDocTypeMap(entitycode);

            Console.WriteLine(map.DestinationFolderName);

            // save data to database
            var newMap = new EntityCodeMap()
            {
                EntityCode = "Test", Fund = "Test", FundManager = "Test", CreatedBy = "s", ModifiedBy = "d"
            };

            _repository.SaveData(newMap);
            Console.WriteLine("data saved");
            // after doing processing save data back to database
            newMap.IsActive = false;
            _repository.UpdateData(newMap);
            Console.WriteLine("data updated");
            //then delete data
            _repository.DeleteData(newMap);
            Console.WriteLine("deleted");
        }