示例#1
0
        public LoginModel LetMeIn(LoginModel model)
        {
            string message = "Invalid username/password";

            model.UserID = 0;
            AAContext context = new AAContext();
            User      user    = context.AsQueryable <User>()
                                .Where(x => x.Username == model.Username.Trim() && x.Password == model.Password.Trim())
                                .FirstOrDefault();

            if (user != null)
            {
                if (user.ID > 0)
                {
                    message        = "";
                    model.UserID   = user.ID;
                    model.RoleID   = user.RoleID;
                    model.Username = user.Username;
                    model.FullName = string.Format("{0}, {1} {2}", user.LastName, user.FirstName, user.MiddleName);
                    model.Email    = user.Email;
                    model.RoleName = user.Role.Name;
                }
            }
            model.Message = message;
            return(model);
        }
示例#2
0
        public void ExecuteSp()
        {
            var       sp      = "sp_CreateRole";
            AAContext context = new AAContext();

            context.ExecuteTSQL("exec sp_CreateRole 'test','testonly'");
        }
示例#3
0
        public void GetTableColumnTestInt()
        {
            AAContext context     = new AAContext();
            string    notExpected = string.Empty;
            string    actual      = string.Empty;

            actual = context.GetColumn <string>("select CAST(ID AS VARCHAR(10)) from [user]");
            Assert.AreNotEqual(notExpected, actual);
        }
示例#4
0
        public void GetTableColumnTest()
        {
            AAContext context     = new AAContext();
            string    notExpected = string.Empty;
            string    actual      = string.Empty;

            actual = context.GetColumn <string>("select username from [user]");
            Assert.AreNotEqual(notExpected, actual);
        }
示例#5
0
        public void GenerateEntity()
        {
            AAContext context     = new AAContext();
            string    notExpected = string.Empty;
            var       user        = new TestUser();
            string    a           = "";
            var       users       = context.GetList <TestUser>("select u.Active,u.Username,u.Password,RoleName=r.Name from [User]  u inner join [Role] r on r.ID=u.RoleID");

            //ctx.
            //context.GetColumn( "select u.Username,u.Password,r.Name from [User] u inner join [Role] r on r.ID=u.RoleID" );
            foreach (var u in users)
            {
                a += u.Username + ":" + u.RoleName + ":" + u.Active + ",";
            }

            Assert.AreNotEqual(notExpected, a);
        }
示例#6
0
        public void InsertUserTest()
        {
            User user = new User()
            {
                Username     = "******",
                Password     = "******",
                FirstName    = "banbanboi",
                LastName     = "banbanboi",
                MiddleName   = "A",
                Address      = "adress 1",
                Phone        = "1234324",
                Email        = string.Format("{0}@gmail.com", "mcnielv"),
                SSS          = "3242332432",
                TIN          = "23432432",
                RoleID       = 1,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            AAContext context = new AAContext();

            context.Add <User>(user);
            context.SaveChanges();
        }
示例#7
0
        public void InsertAircraft()
        {
            Aircraft aircraft = new Aircraft()
            {
                Name         = "AC1" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                Description  = "AC1" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            AAContext context = new AAContext();

            context.Add <Aircraft>(aircraft);
            context.SaveChanges();

            aircraft = new Aircraft()
            {
                Name         = "AC2" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                Description  = "AC2" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            context = new AAContext();
            context.Add <Aircraft>(aircraft);
            context.SaveChanges();

            aircraft = new Aircraft()
            {
                Name         = "AC3" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                Description  = "AC3" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            context = new AAContext();
            context.Add <Aircraft>(aircraft);
            context.SaveChanges();
        }
示例#8
0
 public DestinationService()
 {
     _context = new AAContext();
 }
示例#9
0
 public CalendarService()
 {
     _context     = new AAContext();
     _regService  = new RegistrationService();
     _userService = new UserService();
 }
示例#10
0
 public ReportService()
 {
     _context = new AAContext();
 }
示例#11
0
 public RegistrationService()
 {
     _context = new AAContext();
 }
示例#12
0
 public AircraftTypeService()
 {
     _context = new AAContext();
 }
示例#13
0
 public RoleService()
 {
     _context = new AAContext();
 }
示例#14
0
        public void InsertACRegistration()
        {
            DateTime     datenow = DateTime.Now;
            Registration reg     = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 1,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            AAContext context = new AAContext();

            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 3,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 2,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 3,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 3,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 7,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 7,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 8,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 9,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();

            reg = new Registration()
            {
                Name         = "Reg-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 4),
                AircraftID   = 9,
                Description  = "Test Registration Only",
                DateCreated  = datenow,
                DateModified = datenow
            };
            context = new AAContext();
            context.Add <Registration>(reg);
            context.SaveChanges();
        }
示例#15
0
        public void AttachTest()
        {
            string username = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5);
            User   user     = new User()
            {
                Username     = username,
                Password     = "******",
                FirstName    = username,
                LastName     = username,
                MiddleName   = "A",
                Address      = "adress 1",
                Phone        = "1234324",
                Email        = string.Format("{0}@email.com", username),
                SSS          = "3242332432",
                TIN          = "23432432",
                RoleID       = 1,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            AAContext context = new AAContext();

            context.Add <User>(user);
            context.SaveChanges();

            user = new User()
            {
                Username     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                Password     = "******",
                FirstName    = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                LastName     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                MiddleName   = "A",
                Address      = "adress 1",
                Phone        = "1234324",
                Email        = string.Format("{0}@email.com", username),
                SSS          = "3242332432",
                TIN          = "23432432",
                RoleID       = 6,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            context = new AAContext();
            context.Add <User>(user);
            context.SaveChanges();

            user = new User()
            {
                Username     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                Password     = "******",
                FirstName    = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                LastName     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                MiddleName   = "A",
                Address      = "adress 1",
                Phone        = "1234324",
                Email        = string.Format("{0}@email.com", username),
                SSS          = "3242332432",
                TIN          = "23432432",
                RoleID       = 6,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            context = new AAContext();
            context.Add <User>(user);
            context.SaveChanges();

            user = new User()
            {
                Username     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                Password     = "******",
                FirstName    = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                LastName     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                MiddleName   = "A",
                Address      = "adress 1",
                Phone        = "1234324",
                Email        = string.Format("{0}@email.com", username),
                SSS          = "3242332432",
                TIN          = "23432432",
                RoleID       = 5,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            context = new AAContext();
            context.Add <User>(user);
            context.SaveChanges();

            user = new User()
            {
                Username     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                Password     = "******",
                FirstName    = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                LastName     = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5),
                MiddleName   = "A",
                Address      = "adress 1",
                Phone        = "1234324",
                Email        = string.Format("{0}@email.com", username),
                SSS          = "3242332432",
                TIN          = "23432432",
                RoleID       = 4,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now
            };
            context = new AAContext();
            context.Add <User>(user);
            context.SaveChanges();
        }
示例#16
0
 public LogsService()
 {
     _context = new AAContext();
 }
示例#17
0
 public UserService()
 {
     _context = new AAContext();
 }