//get user by id public users getUserByUserId(int userId) { var user = new users(); try { using (var ctx = new transshipEntities()) { ctx.Configuration.LazyLoadingEnabled = false; user = ctx.users.Where(x => x.userId == userId).SingleOrDefault(); if (user != null) { user.password = TransShip.Security.Security.Decrypt(user.password, new RijndaelManaged(), KEY); } return(user); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public users UpdateUser(users model) { users user = new users(); model.password = TransShip.Security.Security.Encrypt(model.password, new RijndaelManaged(), KEY); user = model; try { using (var ctx = new transshipEntities()) { ctx.Entry(user).State = EntityState.Modified; ctx.SaveChanges(); return(user); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
//get shipment_Notes by shimpentId public List <Notes> getShipNotes(int shipmentId) { var list = new List <Notes>(); Notes notes; try { using (var ctx = new transshipEntities()) { var query = (from sn in ctx.shipment_notes join u in ctx.users on sn.userId equals u.userId where sn.shipmentId == shipmentId orderby sn.creation_date descending select new { username = u.email, userId = u.userId, shipment_noteId = sn.shipment_noteId, note = sn.note, status = sn.status, creation_date = sn.creation_date, shipmentId = sn.shipmentId }).ToList(); foreach (var n in query) { notes = new Notes(); notes.username = n.username; notes.userId = n.userId; notes.shipment_noteId = n.shipment_noteId; notes.note = n.note; notes.status = n.status; notes.creation_date = n.creation_date; notes.shipmentId = n.shipmentId; list.Add(notes); } return(list); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public List <Tracking> getShipTracking(int shipmentId) { var list = new List <Tracking>(); Tracking tracking; try { using (var ctx = new transshipEntities()) { var query = (from sn in ctx.shipment_tracking join u in ctx.users on sn.userId equals u.userId where sn.shipmentId == shipmentId orderby sn.creation_date descending select new { username = u.email, userId = u.userId, trackingId = sn.trackingId, comentaries = sn.comentaries, status = sn.status, creation_date = sn.creation_date, shipmentId = sn.shipmentId }).ToList(); foreach (var n in query) { tracking = new Tracking(); tracking.username = n.username; tracking.userId = n.userId; tracking.trackingId = n.trackingId; tracking.comentaries = n.comentaries; tracking.status = n.status; tracking.creation_date = n.creation_date; tracking.shipmentId = n.shipmentId; list.Add(tracking); } return(list); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
//get all history, filter for idcustomer and idmemberShip public List <History> getHistoy(int idCustomer) { var list = new List <History>(); History h; try { using (var ctx = new transshipEntities()) { var query = (from s in ctx.Memberships_levels join cs in ctx.membership_history on s.membershipId equals cs.membershipId where cs.customerId == idCustomer select new { membership_HistoryId = cs.membership_HistoryId, description = s.description, payment_date = cs.payment_date, initial_date = cs.initial_date, final_date = cs.final_date, memeberShipId = cs.membershipId, custormerId = cs.customerId, }).ToList(); foreach (var p in query) { h = new History(); h.membership_HistoryId = p.membership_HistoryId; h.customerId = p.custormerId; h.description = p.description; h.final_date = p.final_date; h.membershipId = p.memeberShipId; h.initial_date = p.initial_date; h.payment_date = p.payment_date; list.Add(h); } return(list); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public Payments getUser(string email) { var user = new Payments(); Payments p; Memberships_levels m = new Memberships_levels(); try { using (var ctx = new transshipEntities()) { //ctx.Configuration.LazyLoadingEnabled = false; //list = ctx.Memberships_levels.Include("customers").ToList(); var query = (from us in ctx.users join cs in ctx.customers on us.customerId equals cs.customerId join os in ctx.countries on cs.countryId equals os.CountryID where us.email == email select new { status = cs.status, company_name = cs.company_name, customerId = cs.customerId, address1 = cs.address1, address2 = cs.address2, state = cs.state, city = cs.city, Country = os.CountryName, countryId = os.CountryID, expired = cs.expiration_date, contactName = us.full_name, zipcod = cs.zipcode, userId = us.userId, role = us.role, UserType = us.user_type, email = us.email, password = us.password, logo = cs.logo }); foreach (var q in query) { p = new Payments(); p.country = q.Country; p.countryId = q.countryId; p.company_name = q.company_name; p.address1 = q.address1; p.address2 = q.address2; p.city = q.city; if (q.expired != null) { p.expired = q.expired; } else { p.expired = null; } p.contactName = q.contactName; p.zipcode = q.zipcod; p.customerId = q.customerId; p.role = q.role; p.userType = q.UserType; p.userId = q.userId; p.Email = q.email; p.password = TransShip.Security.Security.Decrypt(q.password, new RijndaelManaged(), KEY); p.status = q.status; p.state = q.state; p.logo = q.logo; user = p; } if (user.customerId == 0) { var query2 = (from us in ctx.users where us.email == email select new { userId = us.userId, role = us.role, UserType = us.user_type, email = us.email, password = us.password }); foreach (var q in query2) { p = new Payments(); p.role = q.role; p.userType = q.UserType; p.userId = q.userId; p.Email = q.email; p.password = TransShip.Security.Security.Decrypt(q.password, new RijndaelManaged(), KEY); user = p; } } return(user); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }