public List <GETEquipmentListVM> getEquipmentListByJobsite(long jobsiteAuto, int User) { List <GETEquipmentListVM> result = new List <GETEquipmentListVM>(); if (jobsiteAuto == 0) { return(result); } using (var dataEntitiesShared = new DAL.SharedContext()) { result = (from eqmt in dataEntitiesShared.EQUIPMENT join lu_mmta in dataEntitiesShared.LU_MMTA on eqmt.mmtaid_auto equals lu_mmta.mmtaid_auto join model in dataEntitiesShared.MODEL on lu_mmta.model_auto equals model.model_auto join make in dataEntitiesShared.MAKE on lu_mmta.make_auto equals make.make_auto where eqmt.crsf_auto == jobsiteAuto select new GETEquipmentListVM { equipmentid_auto = eqmt.equipmentid_auto, serialno = eqmt.serialno, unitno = eqmt.unitno, model_auto = model.model_auto, modeldesc = model.modeldesc, makedesc = make.makedesc }).ToList(); } var accessible = new BLL.Core.Domain.UserAccess(new SharedContext(), User).getAccessibleEquipments().Select(m => m.equipmentid_auto); return(result.Where(m => accessible.Any(k => k == m.equipmentid_auto)).ToList()); }
/// <summary> /// Returns a basic list of all user accounts for a given dealership id, if the userId passed in has /// the correct access level requirements to see that dealerships users. /// </summary> /// <param name="userId">The userId requesting to access the customer list</param> /// <param name="customerId">The customerId we want to get a list of user accounts for</param> /// <returns>A BasicUserDataSet object which contains basic user account information</returns> public IEnumerable <BasicUserDataSet> getUserAccountsForDealership(long userId, int dealershipId) { // List of user accounts to be returned List <BasicUserDataSet> userAccountReturn = new List <BasicUserDataSet>(); bool hasAccessToDealership = AuthorizeUserAccess.verifyAccessToDealership(userId, dealershipId, true); bool isGlobalAdmin = AuthorizeUserAccess.isUserGlobalAdministrator(userId); if (hasAccessToDealership) { using (var context = new DAL.SharedContext()) { userAccountReturn = context.UserAccessMaps .Where(um => um.DealershipId == dealershipId) .OrderBy(um => um.USER_TABLE.suspended) .ThenBy(um => um.AccessLevelTypeId) .ThenBy(um => um.USER_TABLE.username) .Select(um => new BasicUserDataSet { UserId = um.USER_TABLE.user_auto, Username = um.USER_TABLE.username, Email = um.USER_TABLE.email, AccessLevel = um.AccessLevelTypeId, Disabled = um.USER_TABLE.suspended, Password = isGlobalAdmin ? um.USER_TABLE.passwd : "******" }).ToList(); } } return(userAccountReturn); }
/// <summary> /// Returns a basic list of all user accounts for a given customer, if the userId passed in has /// the correct access level requirements to see that customer. /// </summary> /// <param name="userId">The userId requesting to access the customer list</param> /// <param name="customerId">The customerId we want to get a list of user accounts for</param> /// <returns>A BasicUserDataSet object which contains basic user account information</returns> public IEnumerable <BasicUserDataSet> getUserAccountsForCustomer(long userId, long customerId) { List <BasicUserDataSet> userAccountReturn = new List <BasicUserDataSet>(); bool hasAccessToCustomer = AuthorizeUserAccess.verifyAccessToCustomer(userId, customerId, true); bool isGlobalAdmin = AuthorizeUserAccess.isUserGlobalAdministrator(userId); if (hasAccessToCustomer) { using (var context = new DAL.SharedContext()) { userAccountReturn = context.UserAccessMaps .Where(um => um.customer_auto == customerId) .Where(um => um.AccessLevelTypeId == (int)UserAccessTypes.CustomerAdministrator || um.AccessLevelTypeId == (int)UserAccessTypes.CustomerUser) .OrderBy(um => um.USER_TABLE.suspended) .ThenBy(um => um.AccessLevelTypeId) .ThenBy(um => um.USER_TABLE.username) .Select(um => new BasicUserDataSet { UserId = um.USER_TABLE.user_auto, Username = um.USER_TABLE.username, Email = um.USER_TABLE.email, AccessLevel = um.AccessLevelTypeId, Disabled = um.USER_TABLE.suspended, Password = isGlobalAdmin ? um.USER_TABLE.passwd : "******" }).ToList(); } } return(userAccountReturn); }
public List <GETEquipmentListVM> getEquipmentListByCustomerAndJobsite(long customerAuto, int jobsiteAuto, int UserId) { var Equipments = getEquipmentListByCustomer(customerAuto, UserId); using (var dataEntitiesShared = new DAL.SharedContext()) { var jobsiteEquipments = dataEntitiesShared.EQUIPMENT.Where(m => m.crsf_auto == jobsiteAuto).Select(m => m.equipmentid_auto); return(Equipments.Where(m => jobsiteEquipments.Any(k => k == m.equipmentid_auto)).OrderBy(l => l.serialno).ToList()); } }
public List <GETEquipmentListVM> getEquipmentListByCustomerAndJobsite(long customerAuto, int jobsiteAuto, System.Security.Principal.IPrincipal User) { var Equipments = getEquipmentListByCustomer(customerAuto, User); using (var dataEntitiesShared = new DAL.SharedContext()) { var jobsiteEquipments = dataEntitiesShared.EQUIPMENT.Where(m => m.crsf_auto == jobsiteAuto).Select(m => m.equipmentid_auto); return(Equipments.Where(m => jobsiteEquipments.Any(k => k == m.equipmentid_auto)).ToList()); } }
public long currentSMU(string equipmentid_auto) { long result = 0; long iEqmtIDAuto = long.TryParse(equipmentid_auto, out iEqmtIDAuto) ? iEqmtIDAuto : 0; using (var dataEntities = new DAL.SharedContext()) { var equipmentSMU = dataEntities.EQUIPMENT.Find(iEqmtIDAuto).currentsmu; if (equipmentSMU != null) { result = equipmentSMU.Value; } } return(result); }
private bool Init(DbContext sharedContext, int oldUserId) { try { _context = (DAL.SharedContext)sharedContext; if (oldUserId <= 0) { return(false); } DALUser = _context.USER_TABLE.Find(oldUserId); if (DALUser == null) { return(false); } Initialized = true; } catch (Exception ex) { string message = ex.Message; } return(Initialized); }
public List <GETEquipmentListVM> getEquipmentListByCustomer(long customerAuto, System.Security.Principal.IPrincipal User) { List <GETEquipmentListVM> result = new List <GETEquipmentListVM>(); if (customerAuto == 0) { return(result); } using (var dataEntitiesShared = new DAL.SharedContext()) { result = (from eqmt in dataEntitiesShared.EQUIPMENT join crsf in dataEntitiesShared.CRSF on eqmt.crsf_auto equals crsf.crsf_auto join customer in dataEntitiesShared.CUSTOMER on crsf.customer_auto equals customer.customer_auto join lu_mmta in dataEntitiesShared.LU_MMTA on eqmt.mmtaid_auto equals lu_mmta.mmtaid_auto join model in dataEntitiesShared.MODEL on lu_mmta.model_auto equals model.model_auto join make in dataEntitiesShared.MAKE on lu_mmta.make_auto equals make.make_auto where customer.customer_auto == customerAuto select new GETEquipmentListVM { equipmentid_auto = eqmt.equipmentid_auto, serialno = eqmt.serialno, unitno = eqmt.unitno, modeldesc = model.modeldesc, makedesc = make.makedesc, customer_auto = customer.customer_auto, cust_name = customer.cust_name }).ToList(); } var accessible = new BLL.Core.Domain.UserAccess(new SharedContext(), User).getAccessibleEquipments().Select(m => m.equipmentid_auto); return(result.Where(m => accessible.Any(k => k == m.equipmentid_auto)).ToList()); }
public JobSite(DAL.SharedContext context) : base(context) { }
public JobSite(DAL.SharedContext context, int Id) : base(context) { this.Id = Id; }