Exemplo n.º 1
0
        public void DetachRepository(TEntity updated, int entryId)
        {
            var local = context.Set <Company>().Local.FirstOrDefault(entry => entry.Id.Equals(entryId));

            if (local != null)
            {
                context.Entry(local).State = EntityState.Detached;
            }
            context.Entry(updated).State = EntityState.Modified;
        }
        public IViewComponentResult Invoke(string id)
        {
            var                    username   = User.Identity.Name;
            var                    isAdmin    = User.IsInRole("Admin");
            ApplicationUser        currUser   = context.Set <ApplicationUser>().FirstOrDefault(woak => woak.UserName.Equals(username));
            List <ApplicationUser> companyIds = null;

            companyIds = context.Set <ApplicationUser>().ToList();

            var model = companyIds.Select(x => new KeyTextViewModel
            {
                Id         = x.Id,
                Text       = x.UserName,
                IsSelected = x.Id == id
            }).ToList();

            return(View(model));
        }
Exemplo n.º 3
0
        public void DetachRepository(TEntity updated, string entryId)
        {
            var local = context.Set <Company>().Local.FirstOrDefault(entry => entry.Id.Equals(entryId));

            // check if local is not null
            if (local != null) // I'm using a extension method
            {
                // detach
                context.Entry(local).State = EntityState.Detached;
            }
            // set Modified flag in your entry
            context.Entry(updated).State = EntityState.Modified;
        }
        public IViewComponentResult Invoke(int?id, int DomainID)
        {
            var username  = User.Identity.Name;
            var isAdmin   = User.IsInRole("Admin");
            var domainIds = context.Set <DomainSetting>()
                            .Include(x => x.Server)
                            .Select(x => x.Id).ToList();

            var model = this.context.Set <DomainSetting>().Where(x => domainIds.Contains(x.Id) || isAdmin)
                        .Select(x => new KeyTitleViewModel
            {
                Id         = x.Id,
                Title      = x.Title,
                IsSelected = x.Id == id
            }).ToList();

            return(View(model));
        }
        public IViewComponentResult Invoke(string id)
        {
            var Roles = new List <string>();

            //  if (string.IsNullOrEmpty(id))

            Roles = context.Set <ApplicationRole>().Select(x => x.Id).ToList();

            var model = this.context.Set <ApplicationRole>().Where(x => Roles.Contains(x.Id))
                        .Select(x => new KeyTextViewModel
            {
                Id         = x.Id,
                Text       = x.Name,
                IsSelected = x.Id == id
            }).ToList();

            return(View(model));
        }
Exemplo n.º 6
0
 public PortfoRepository(KavoshFrameWorkCore.KavoshFrameWorkContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <CompanyShareholder>();
 }
Exemplo n.º 7
0
 public TreeRepository(KavoshFrameWorkCore.KavoshFrameWorkContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Exemplo n.º 8
0
 public ApplicationUserRepository(KavoshFrameWorkCore.KavoshFrameWorkContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <ApplicationUser>();
 }