/// <summary> /// constructor /// </summary> public BaseEntityManager() { if (_dbContext == null) { _dbContext = CurrentContext; } }
private Leg GetLeg(WFPICTContext db, Guid id) { return(db.Legs .Include(x => x.FromLocation) .Include(x => x.ToLocation) .FirstOrDefault(x => x.Id == id)); }
public static void GeneratePODForm(WFPICTContext Db, string UploadsFormsPath, string DownloadsFormsPath, string SignPath, Guid Id) { Proof pod = Db.Proofs .Include(x => x.Assignment) .Include(x => x.Assignment.Order) .Include(x => x.Pictures) .Include(x => x.Piano) .Include(x => x.Piano.Statuses) .FirstOrDefault(x => x.Id == Id) ; string templateFormsPath = Path.Combine(UploadsFormsPath, pod.Assignment.Order.DeliveryForm); string podFileName = "POD" + pod.Assignment.Order.OrderNumber + ".pdf"; string podFilePath = Path.Combine(DownloadsFormsPath, pod.Id.ToString() + ".pdf"); string signature = Path.Combine(SignPath, pod.Signature); string signatureResized = Path.Combine(SignPath, "1" + pod.Signature); if (!System.IO.File.Exists(signatureResized)) { ImageResizer.Resize(signature, signatureResized, 150, 150, true); } GeneratePODForm(templateFormsPath, podFilePath, pod.ReceivedBy, pod.ReceivingTime?.ToString(), signatureResized); EmailHelper.SendEmail(pod.Assignment.Order.CallerEmail, "Signed POD Form " + podFileName, "Please find attached Signed Delivery Form " + podFileName, "", new string[] { podFilePath }.ToList()); }
private static void AddClaims(WFPICTContext ctx, RoleManager <WFPRole> RoleManager, string Role, string[] permissions) { var role = RoleManager.FindByName(Role); foreach (var permisson in permissions) { var claim = ctx.Claims.FirstOrDefault(x => x.ClaimValue == permisson); AddClaim(ctx, role.Id, claim.Id); } }
public void AddClaim(WFPICTContext ctx, string roleId, Guid claimID) { ctx.RoleClaims.Add(new AspNetRoleClaims() { Id = Guid.NewGuid(), RoleID = roleId, ClaimID = claimID, CreatedAt = DateTime.Now }); ctx.SaveChanges(); }
/// <summary> /// public constructor that use existing object /// </summary> public BaseEntityManager(WFPICTContext dbContext) { if (dbContext != null) { _dbContext = dbContext; } else { string message = "BaseEntityManager constructor, entity name " + EntityName() + ": dbContext object can't be NULL !"; throw new Exception(message); } }
public void Configuration(IAppBuilder app) { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo("en-US"); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); ConfigureAuth(app); using (var db = new WFPICTContext()) { var ad = db.Addresses.FirstOrDefault(); } GlobalConfiguration.Configuration.UseSqlServerStorage("WFPICTContext"); //app.UseHangfireDashboard(); app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new HangfireAuthorizationFilter() } }); app.UseHangfireServer(); }
public AspNetRoleClaimsManager(WFPICTContext context) : base(context) { }
public GenericRepository(WFPICTContext context) { this.context = context; this.dbSet = context.Set <TEntity>(); }
public static void Seed(WFPICTContext context) { #region Order Guid typeID = Guid.NewGuid(); // Piano Types foreach (var ptype in EnumHelper.GetEnumTextValues(typeof(PianoTypeEnum))) { var already = context.PianoTypes.FirstOrDefault(m => m.Code == ptype.Value); if (already == null) { context.PianoTypes.Add(new PianoType() { Id = ptype.Text == "Spinet" ? typeID : Guid.NewGuid(), CreatedAt = DateTime.Now, Code = ptype.Value, Type = ptype.Text, }); } } context.SaveChanges(); //Piano Make foreach (var ptype in EnumHelper.GetEnumTextValues(typeof(PianoMakeEnum))) { var already = context.PianoMake.FirstOrDefault(m => m.Name == ptype.Text); if (already == null) { context.PianoMake.Add(new PianoMake() { Id = Guid.NewGuid(), Code = ptype.Value, Name = ptype.Text, CreatedAt = DateTime.Now, }); } } context.SaveChanges(); // Piano Finish foreach (var finish in EnumHelper.GetEnumTextValues(typeof(PianoFinishEnum))) { var already = context.PianoFinish.FirstOrDefault(m => m.Code == finish.Value); if (already == null) { context.PianoFinish.Add(new PianoFinish() { Id = Guid.NewGuid(), Code = finish.Value, Name = finish.Text, CreatedAt = DateTime.Now, }); } } context.SaveChanges(); //PianoSizes context.PianoSize.Add(new PianoSize() { Id = Guid.NewGuid(), PianoTypeId = typeID, Width = 235.56, CreatedAt = DateTime.Now, }); context.SaveChanges(); context.PianoSize.Add(new PianoSize() { Id = Guid.NewGuid(), PianoTypeId = typeID, Width = 180.34, CreatedAt = DateTime.Now, }); context.SaveChanges(); // Piano Charges int code = 100; foreach (var ptype in EnumHelper.GetEnumTextValues(typeof(ChargesTypeEnum))) { string officeCode = ptype.Value; var already = context.PianoCharges.FirstOrDefault(m => m.Details.ToString() == officeCode); if (already == null) { var rnd = new Random(DateTime.Now.Millisecond); context.PianoCharges.Add(new PianoCharges() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, Code = code.ToString(), Details = ptype.Text, Amount = rnd.Next(1000) }); code += 100; } } context.SaveChanges(); // Test Client var clientId = Guid.NewGuid(); var addressId = Guid.NewGuid(); context.Clients.Add(new Client() { Id = clientId, CreatedAt = DateTime.Now, ClientType = 1, AccountCode = "456343", Name = "Test Client 1", PhoneNumber = "12345678", EmailAddress = "*****@*****.**", Comment = "Its test Client", }); context.SaveChanges(); // Test Address context.Addresses.Add(new Address() { Id = addressId, CreatedAt = DateTime.Now, ClientId = clientId, Name = "Client Person Name", Address1 = "Complete Address", PhoneNumber = "1234", PostCode = "123", State = "CA", City = "City name", Lat = "34.504772", Lng = "-117.221566", }); context.SaveChanges(); var client = context.Clients.FirstOrDefault(); if (client != null) { client.AddressId = addressId; context.SaveChanges(); } #endregion #region Delivery // Vehicles Types var vehicleTypeId1 = Guid.NewGuid(); var vehicleTypeId2 = Guid.NewGuid(); context.VehicleTypes.Add(new VehicleType() { Id = vehicleTypeId1, CreatedAt = DateTime.Now, Code = "101", Name = "Truck", }); context.VehicleTypes.Add(new VehicleType() { Id = vehicleTypeId2, CreatedAt = DateTime.Now, Code = "102", Name = "Trailer", }); context.SaveChanges(); var vehicle1 = Guid.NewGuid(); var vehicle2 = Guid.NewGuid(); var vehicle3 = Guid.NewGuid(); context.Vehicles.Add(new Vehicle() { Id = vehicle1, CreatedAt = DateTime.Now, Code = "5876", Name = "Truck ABC", VehicleTypeId = vehicleTypeId1 }); context.Vehicles.Add(new Vehicle() { Id = vehicle2, CreatedAt = DateTime.Now, Code = "4272", Name = "Truck XYZ", VehicleTypeId = vehicleTypeId1 }); context.Vehicles.Add(new Vehicle() { Id = vehicle3, CreatedAt = DateTime.Now, Code = "633", Name = "Trailer X", VehicleTypeId = vehicleTypeId2 }); context.SaveChanges(); // Drivers context.Drivers.Add(new Driver() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, Code = "D101", Password = "******", Name = "Driver 1 Name", Description = "This is test Driver 1", }); context.Drivers.Add(new Driver() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, Code = "D102", Password = "******", Name = "Driver 2 Name", Description = "This is Driver 2", }); context.SaveChanges(); // Warehouse var warehouse = new Warehouse() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, Code = "W101", Name = "ENCORE PIANO MOVING Warehouse 101", Address1 = "15915 CANARY AVE.", PhoneNumber = "(714) 739-4717", PostCode = "90638", State = "CA", City = "LA MIRADA", Lat = "33.892162", Lng = "-118.024756" }; context.Warehouses.Add(warehouse); var locations = new string[] { "Los Angeles", "San Francisco", "Anaheim" }; foreach (var l in locations) { context.Locations.Add(new Location() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, Name = l }); } context.SaveChanges(); #endregion }
public static void Seed(WFPICTContext context) { // Permissions foreach (var permission in SecurityConstants.ClaimsAll) { context.Claims.Add(new AspNetClaims() { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, ClaimType = permission.Contains(PermissionType.Order.ToLower()) ? PermissionType.Order : PermissionType.Permission, ClaimValue = permission }); } context.SaveChanges(); // Roles var RoleManager = new RoleManager <WFPRole>(new RoleStore <WFPRole>(context)); if (!RoleManager.RoleExists(SecurityConstants.RoleAdmin)) { RoleManager.Create(new WFPRole(SecurityConstants.RoleAdmin, false, false, "Admin Role")); AddClaims(context, RoleManager, SecurityConstants.RoleAdmin, SecurityConstants.ClaimsAdmin); } if (!RoleManager.RoleExists(SecurityConstants.RoleEmployee)) { RoleManager.Create(new WFPRole(SecurityConstants.RoleEmployee, false, false, "Employee Role")); AddClaims(context, RoleManager, SecurityConstants.RoleEmployee, SecurityConstants.ClaimsAdmin); } if (!RoleManager.RoleExists(SecurityConstants.RolePrivate)) { RoleManager.Create(new WFPRole(SecurityConstants.RolePrivate, false, false, "Private Role")); AddClaims(context, RoleManager, SecurityConstants.RolePrivate, SecurityConstants.ClaimsDefault); } if (!RoleManager.RoleExists(SecurityConstants.RoleDealer)) { RoleManager.Create(new WFPRole(SecurityConstants.RoleDealer, false, false, "Dealer Role")); AddClaims(context, RoleManager, SecurityConstants.RoleDealer, SecurityConstants.ClaimsDefault); } if (!RoleManager.RoleExists(SecurityConstants.RoleManufacturer)) { RoleManager.Create(new WFPRole(SecurityConstants.RoleManufacturer, false, false, "Manufacturer Role")); AddClaims(context, RoleManager, SecurityConstants.RoleManufacturer, SecurityConstants.ClaimsDefault); } var UserManager = new UserManager <WFPUser>(new UserStore <WFPUser>(context)); var alreadyAdminUser = UserManager.FindByName(SecurityConstants.UserAdmin); if (alreadyAdminUser == null) { var adminUser = new WFPUser() { Id = Guid.NewGuid().ToString(), UserName = SecurityConstants.UserAdmin, Email = "*****@*****.**", FirstName = "Admin", LastName = "User", CreatedAt = DateTime.Now }; var result = UserManager.CreateAsync(adminUser, SecurityConstants.UserAdminPassword); if (result.Result == IdentityResult.Success) { var result1 = UserManager.AddToRole(adminUser.Id, SecurityConstants.RoleAdmin); } } var alreadyTestUser = UserManager.FindByName(SecurityConstants.TestEmployeeUser); if (alreadyTestUser == null) { var user = new WFPUser() { Id = Guid.NewGuid().ToString(), UserName = SecurityConstants.TestEmployeeUser, Email = "*****@*****.**", FirstName = "Test", LastName = "User", CreatedAt = DateTime.Now }; var result = UserManager.CreateAsync(user, SecurityConstants.UserAdminPassword); if (result.Result == IdentityResult.Success) { var result1 = UserManager.AddToRole(user.Id, SecurityConstants.RolePrivate); } } }
public CompanyManager(WFPICTContext context) : base(context) { }