public void CreateCrews(CrewViewModel model) { var crew = new ScheduleCrew() { CrewID = model.CrewID, ScheduleID = model.ScheduleID }; _context.Add <ScheduleCrew>(crew); _context.SaveChanges(); }
public string Create(LogsViewModel model) { string msg = string.Empty; try { Logs log = new Logs() { ActionType = model.ActionType, Description = model.Description, DateModified = DateTime.Parse(model.DateModified), ModifiedBy = model.ModifiedBy }; _context.Add <Logs>(log); _context.SaveChanges(); msg = "Log Created."; } catch (Exception ex) { LogsViewModel error = new LogsViewModel() { ActionType = ActionType.Error.ToString(), Description = ex.Message + "\n" + ex.StackTrace, ModifiedBy = "Log Service Error", DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm") }; this.Create(error); msg = "Unexpected error encountered. Please contact your system administrator."; } return(msg); }
public string Create(UserViewModel model) { string msg = string.Empty; try { var ctr = _context.AsQueryable <User>().Where(x => x.Username == model.Username || x.Email == model.Email).Count(); if (ctr > 0) { msg = "Your profile email or username already exists."; } else { User user = new User() { RoleID = model.RoleID, Username = model.Username, Password = ThreeDES.Encrypt("Password1"),//DEFAULT PASSWORD: Password1 FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, Email = model.Email, Address = model.Address ?? "", Phone = model.Phone ?? "", SSS = model.SSS ?? "", TIN = model.TIN ?? "", DateCreated = DateTime.Now, DateModified = DateTime.Now, Active = true }; _context.Add <User>(user); _context.SaveChanges(); msg = "New profile added."; } } catch (Exception ex) { LogsViewModel error = new LogsViewModel() { ActionType = ActionType.Error.ToString(), Description = ex.Message + "\n" + ex.StackTrace, ModifiedBy = "User Service Error : Create()", DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm") }; new LogsService().Create(error); msg = "Unexpected error encountered. Please contact your system administrator."; } return(msg); }
public string Create(RegistrationViewModel model) { string msg = string.Empty; try { var ctr = _context.AsQueryable <Registration>().Where(x => x.Name == model.Name).Count(); if (ctr > 0) { msg = "Aircraft registration already exists."; } else { Registration registration = new Registration() { Name = model.Name, Description = model.Description, AircraftID = model.AircraftID, DateCreated = DateTime.Now, DateModified = DateTime.Now }; _context.Add <Registration>(registration); _context.SaveChanges(); msg = "Aircraft registration added."; } } catch (Exception ex) { //TODO: Log Error here. msg = "Unexpected error encountered. Please contact your system administrator."; LogsViewModel error = new LogsViewModel() { ActionType = ActionType.Error.ToString(), Description = ex.Message + "\n" + ex.StackTrace, ModifiedBy = "Registration Service Error : Create()", DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm") }; new LogsService().Create(error); } return(msg); }
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(); }
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(); }
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(); }
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(); }