public bool Add(Entities.Corporation corporation)
 {
     try
     {
         corporation.CreatedDate     = DateTime.Now;
         corporation.CreatedByUserId = DatabaseTools.GetUserID;
         contaxt.Corporations.Add(corporation);
         contaxt.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool Update(Entities.Corporation corporation)
 {
     try
     {
         var _corporation = contaxt.Corporations.Where(p => p.CorporationId == corporation.CorporationId).FirstOrDefault();
         _corporation                 = corporation;
         _corporation.ChangedDate     = DateTime.Now;
         _corporation.ChangedByUserId = DatabaseTools.GetUserID;
         contaxt.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #3
0
        public CorporationRepositoryTests()
        {
            var contaxt     = new DataLayer.InventoryDBContext();
            var relateduser = contaxt.Users.FirstOrDefault(u => u.Username.Equals("admin"));
            var identity    = new GenericIdentity(relateduser.Username);
            var roles       = relateduser.Roles.Select(p => p.Title).ToArray();
            var principal   = new GenericPrincipal(identity, roles);

            System.Threading.Thread.CurrentPrincipal = principal;
            corp  = new Repositories.CorporationRepository();
            ECorp = new Entities.Corporation()
            {
                Title       = "Title",
                Address     = "Address",
                Telephone   = "Telephone",
                Description = "Description",
            };
        }