Пример #1
0
        public Term Build(IMiteryaDBContext _context)
        {
            this._context = _context;
            Term tempTerm = _context.Terms.Where(i => i.IsActive == true).FirstOrDefault();

            if (tempTerm != null)
            {
                tempTerm.IsActive = false;
                this._context.Entry(tempTerm);
            }

            #region basemodel operations
            this.term.DateCreated  = DateTime.Now;
            this.term.DateModified = DateTime.Now;
            this.term.IsActive     = true;
            this.term.IsDeleted    = false;
            #endregion

            #region db actions
            this._context.Terms.Add(this.term);
            this._context.SaveChanges();
            #endregion

            return(this.term);
        }
Пример #2
0
        public void SetAccessClassrooms(IMiteryaDBContext _context, User user, List <Guid> classes)
        {
            this._context = _context;

            UserOrganizationRole uor = this._context.UserOrganizationRoles.Find(user);

            foreach (var item in classes)
            {
                uor.AccessClassroomIds = string.Join(",", item);
            }

            this._context.Entry(uor);
            this._context.SaveChanges();
        }
Пример #3
0
        public void SetAccessClassroom(IMiteryaDBContext _context, Guid userId, Guid clss)
        {
            this._context = _context;

            UserOrganizationRole uor = this._context.UserOrganizationRoles.Where(i => i.UserId == userId && i.IsActive == true).FirstOrDefault();

            if (String.IsNullOrEmpty(uor.AccessClassroomIds))
            {
                uor.AccessClassroomIds = clss.ToString();
            }
            else
            {
                uor.AccessClassroomIds += "," + clss.ToString();// (",", clss); bu parantezli yapiyi yazinca (,, GUID) seklinde kayit atiyor mantigi incele
            }
            this._context.Entry(uor);
            this._context.SaveChanges();
        }
Пример #4
0
        public void AddRole(IMiteryaDBContext _context, RoleEnum role, Term term, Organization organization)
        {
            this._context = _context;

            UserOrganizationRole newRole = new UserOrganizationRole
            {
                Id                  = Guid.NewGuid(),
                IsActive            = true,
                DateCreated         = DateTime.Now,
                DateModified        = DateTime.Now,
                UserCreated         = this.user.Id,
                IsDeleted           = false,
                UserId              = this.user.Id,
                OrganizationId      = organization.Id,
                RoleId              = this._context.Roles.AsNoTracking().FirstOrDefault(a => a.Code == (int)role).Id,
                TermId              = term.Id,
                AccessClassroomIds  = null,
                UserDashboardModule = null
            };

            this._context.UserOrganizationRoles.Add(newRole);
            this._context.SaveChanges();
        }