Exemplo n.º 1
0
        public bool Register(Account accountParam)
        {
            Account account = new Account();

            byte[] salt     = null;
            byte[] password = null;

            account = _topContext.Accounts.FirstOrDefault(x => x.Username == accountParam.Username);

            if (account != null)
            {
                return(false);
            }

            salt     = CreateSalt();
            password = HashPassword(accountParam.Password, salt);
            account  = new Account
            {
                Username = accountParam.Username,
                Salt     = Convert.ToBase64String(salt),
                Password = Convert.ToBase64String(password),
                Role     = accountParam.Role
            };

            _topContext.Accounts.Add(account);
            _topContext.SaveChanges();
            return(true);
        }
Exemplo n.º 2
0
        public Company Add(Company companyParam)
        {
            Company company = new Company();

            company = _topContext.Companys.FirstOrDefault(x => x.company == companyParam.company);

            if (company != null)
            {
                return(null);
            }
            _topContext.Companys.Add(companyParam);
            _topContext.SaveChanges();
            return(companyParam);
        }
Exemplo n.º 3
0
        public Teacher Add(Teacher teacherParam)
        {
            Teacher teacher = new Teacher();

            teacher = _topContext.Teachers.FirstOrDefault(x => x.teacher == teacherParam.teacher);

            if (teacher != null)
            {
                return(teacher);
            }

            _topContext.Teachers.Add(teacherParam);
            _topContext.SaveChanges();
            return(teacherParam);
        }
Exemplo n.º 4
0
        public Address Add(Address addressParam)
        {
            Address address = new Address();

            address = _topContext.Addresses.FirstOrDefault(x => x.address == addressParam.address);

            if (address != null)
            {
                return(null);
            }

            _topContext.Addresses.Add(addressParam);
            _topContext.SaveChanges();
            return(addressParam);
        }
Exemplo n.º 5
0
        public VocationalQualificationUnit Add(VocationalQualificationUnit vocationalQualificationUnitParam)
        {
            VocationalQualificationUnit vocationalQualificationUnit = new VocationalQualificationUnit();

            vocationalQualificationUnit = _topContext.VocationalQualificationUnits.FirstOrDefault(
                x => x.vocationalQualificationUnit == vocationalQualificationUnitParam.vocationalQualificationUnit);

            if (vocationalQualificationUnit != null)
            {
                return(vocationalQualificationUnit);
            }

            _topContext.VocationalQualificationUnits.Add(vocationalQualificationUnitParam);
            _topContext.SaveChanges();
            return(vocationalQualificationUnitParam);
        }
Exemplo n.º 6
0
 public void AddTOP(TOPTable top)
 {
     _topContext.TOPs.Add(top);
     _topContext.SaveChanges();
 }