public ApiResult <LoggedInUser> Login(Login login) { try { string domainName = GetDomainName(login.Username); // Extract domain name form provide DomainUsername e.g Domainname\Username string userName = GetUsername(login.Username); // Extract user name from provided DomainUsername e.g Domainname\Username IntPtr token = IntPtr.Zero; bool valid = LogonUser(userName, domainName, login.Password, 2, 0, ref token); if (valid) { var user = this.loginRepository.GetLoggedInUser(userName, login.Password, login.Role); if (user != null) { FormsAuthentication.SetAuthCookie(login.Username, false); return(ApiResult <LoggedInUser> .Success(user)); } else { throw new Exception("Invalid Username or Password or Role."); } } else { throw new Exception("Invalid Username or Password or Role."); } } catch (Exception ex) { return(ApiResult <LoggedInUser> .Exception(this.logger.LogException(ex))); } }
public ApiResult <string> Update(LabSample model) { try { this.labSampleRepository.UppdateLabSample(model); return(ApiResult <string> .Success(RecordConstants.Update)); } catch (Exception exception) { return(ApiResult <string> .Exception(this.logger.LogException(exception))); } }
public ApiResult <string> Logout() { try { FormsAuthentication.SignOut(); return(ApiResult <string> .Success("User Logged Out.")); } catch (Exception ex) { return(ApiResult <string> .Exception(this.logger.LogException(ex))); } }
public ApiResult <ListResponse <LabSample> > ViewSamples(LabSampleRequest request) { try { var result = this.labSampleRepository.ViewSamples(request.userId, request.roleName, request.product_line, request.product_unit, request.product_desc); return(ApiResult <ListResponse <LabSample> > .Success(new ListResponse <LabSample>() { Items = result, Count = result.Count })); } catch (Exception exception) { return(ApiResult <ListResponse <LabSample> > .Exception(this.logger.LogException(exception))); } }