public void AddLog(ErrorLogModel errorLogModel)
        {
            ErrorLogs _errorLogs = new ErrorLogs();

            _errorLogs = Mapper.Map <ErrorLogModel, ErrorLogs>(errorLogModel);
            _context.ErrorLogs.Add(_errorLogs);
            _context.SaveChanges();
        }
Esempio n. 2
0
 public int InsertUpdateTest(MstTestModel mstTestModel)
 {
     try
     {
         MstTest _mstTest = new MstTest();
         mstTestModel.TestDate = mstTestModel.TestDate.Value.AddDays(1);
         _mstTest = _context.MstTest.Where(x => x.Id == mstTestModel.Id).FirstOrDefault();
         _mstTest = Mapper.Map <MstTestModel, MstTest>(mstTestModel);
         if (_mstTest.Id == 0)
         {
             _context.MstTest.Add(_mstTest);
         }
         _context.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         _errorLog.BindErrorLogModel("InsertUpdateTest", ex.Message, "error");
         return(-1);
     }
 }
        public SystemUsers Create(SystemUsers user, string password)
        {
            // validation
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new AppException("Password is required");
            }

            if (_context.SystemUsers.Any(x => x.Username == user.Username))
            {
                throw new AppException("Username \"" + user.Username + "\" is already taken");
            }

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            _context.SystemUsers.Add(user);
            _context.SaveChanges();

            return(user);
        }