Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [WebGet(UriTemplate = "{deviceId}/{username=null}/{password=null}")]
- public IEnumerable<Session> Get(string username, string password, string deviceId)
- {
- if (String.IsNullOrEmpty(username))
- throw new HttpResponseException(HttpStatusCode.BadRequest);
- if (String.IsNullOrEmpty(password))
- throw new HttpResponseException(HttpStatusCode.BadRequest);
- var session = new List<Session>();
- var employee = db.EEEs
- .Where(e => e.MBL_WORKER_ID == username && e.MBL_WORKER_PIN == password)
- .SingleOrDefault();
- var device = db.PMS_MBL_DVCs
- .Where(d => d.AUID == deviceId)
- .SingleOrDefault();
- if (employee == null || device == null)
- throw new HttpResponseException(HttpStatusCode.NoContent);
- try
- {
- device = db.mbl_update_device_suid(device.DVC_ID).AsQueryable<PMS_MBL_DVC>().FirstOrDefault();
- }
- catch (Exception ex)
- {
- throw new HttpResponseException(HttpStatusCode.InternalServerError);
- }
- session.Add(new Session { SessionID = 1, result = "success", employeeId = employee.EE_ID, uniqueId = device.SUID.ToString() });
- return session;
- }
Add Comment
Please, Sign In to add comment