Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProfileInfo
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- //....
- public ProfileAddress Address { get; set; }
- public ProfileDriverLicense DriverLicense { get; set; }
- public ProfileEmergency Emergency { get; set; }
- public ProfileEmployment Employment { get; set; }
- public ProfileCompensation Compensation { get; set; }
- public ProfileFuel Fuel { get; set; }
- public ProfileCompanyInfo CompanyInfo { get; set; }
- }
- public class ProfileAddress
- {
- public string Address { get; set; }
- public string City { get; set; }
- public string State { get; set; }
- public string Zip { get; set; }
- }
- public class ProfileDriverLicense
- {
- //....
- }
- public class ProfileEmergency
- {
- //....
- }
- public class ProfileEmployment
- {
- //....
- }
- public class ProfileCompensation
- {
- //....
- }
- public class ProfileFuel
- {
- //....
- }
- public class ProfileCompanyInfo
- {
- //....
- }
- public ProfileInfo GetProfile(string username)
- {
- var profile = _db.Drivers.Where(p => p.AspNetUser.UserName == username).Select(k => new ProfileInfo()
- {
- FirstName = k.AspNetUser.FirstName,
- LastName = k.AspNetUser.LastName,
- Username = username,
- Address = new ProfileAddress()
- {
- Address = k.StreetAddress,
- City = k.City,
- State = k.State,
- Zip = k.ZIP
- },
- AvatarUrl = k.AvatarUrl,
- CompanyInfo = new ProfileCompanyInfo()
- {
- //....
- },
- Compensation = new ProfileCompensation()
- {
- //....
- },
- DateOfBirth = k.DOB,
- DriverLicense = new ProfileDriverLicense()
- {
- //....
- },
- Email = k.AspNetUser.UserName,
- Emergency = new ProfileEmergency()
- {
- //....
- },
- Employment = new ProfileEmployment()
- {
- //....
- },
- Fuel = new ProfileFuel()
- {
- //....
- },
- Phone = k.PhoneNo,
- SSN = k.SSN,
- Notes = k.Notes,
- Truck = (k.Truck != null) ? k.Truck.TruckNo : null,
- Trailer = (k.Trailer != null) ? k.Trailer.TrailerNo : null
- }).FirstOrDefault();
- if (profile == null)
- throw new Domain.InvalidDriverException(username);
- return profile;
- }
- [HttpGet]
- [Route("MyProfile")]
- public HttpResponseMessage GetProfile()
- {
- string username = GetUsernameFromClaims();
- if (String.IsNullOrWhiteSpace(username))
- return Request.CreateErrorResponse(HttpStatusCode.NotFound, "User not found");
- var profile = _serviceDriver.GetProfile(username);
- return Request.CreateResponse<Domain.POCO.Profile.ProfileInfo>(profile);
- }
Add Comment
Please, Sign In to add comment