public IHttpActionResult DeleteDoctor(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty) { var doctorModel = this._doctorMapper.Map(WebCommon.Instance.GetObject <DoctorViewModel>(requestCarrier.PayLoad)); doctorModel.TenantID = requestCarrier.TanentId; var userResponse = _dataServices.DoctorService.DeleteDoctor(doctorModel); if (userResponse.Success) { response = new ResponseCarrier() { Status = true, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = userResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult RedirectUrl(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.PayLoad != null) { string tinyUrl = requestCarrier.PayLoad.ToString(); var urlMapping = _tinyURLRepository.GetURLMapping(tinyUrl); if (urlMapping != null && !string.IsNullOrEmpty(urlMapping.TinyUrl)) { response = new ResponseCarrier() { Status = true, PayLoad = urlMapping.Url, ErrorMessage = string.Empty }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Request URL not provided." }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Request URL not provided." }; } return(Json(response)); }
public IHttpActionResult GetMappedDoctorForUser(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { string code = requestCarrier.PayLoad.ToString(); Int64 userId = requestCarrier.UserId.Value; var lstDoctorsModel = _dataServices.DoctorService.GetMappedDoctorForUser(userId, requestCarrier.TanentId); if (lstDoctorsModel != null) { var lstDoctorViewModel = _doctorMapper.MapDoctorShortModel(lstDoctorsModel); response = new ResponseCarrier() { Status = true, PayLoad = lstDoctorViewModel, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "No Doctor is mapped to this user.", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult MapDoctor(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { string code = Convert.ToString(requestCarrier.PayLoad); Int64 userId = (Int64)requestCarrier.UserId.Value; Int64 createdBy = (int)requestCarrier.UserId.Value; Int64 createdByEntity = Convert.ToInt32(requestCarrier.From); string isMapped = _dataServices.DoctorService.MapDoctorToUser(userId, code, requestCarrier.TanentId, createdBy, createdByEntity); if (string.IsNullOrEmpty(isMapped)) { response = new ResponseCarrier() { Status = true, PayLoad = true, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = isMapped, TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetConsultationPrescreptions(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { Int64 userId = requestCarrier.UserId.Value; Int64 consultationId = Convert.ToInt64(requestCarrier.PayLoad); var result = _dataServices.ConsultationService.GetConsultationPrescriptions(consultationId, requestCarrier.TanentId); response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetConsultations(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { Int64 userId = requestCarrier.UserId.Value; var result = _dataServices.DoctorService.GetConsultations(userId, requestCarrier.TanentId); var lstConsultationViewModel = _doctorMapper.MapDoctorConsultation(result); response = new ResponseCarrier() { Status = true, PayLoad = lstConsultationViewModel, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetConsultationMessages(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { Int64 consultationId = (Int64)requestCarrier.PayLoad; var result = _dataServices.ConsultationService.GetMessages(consultationId, requestCarrier.TanentId); if (result != null) { var lstMessageViewModel = _consultationMapper.MapMessages(result); response = new ResponseCarrier() { Status = true, PayLoad = lstMessageViewModel, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = "No Message Retrived for input consultation" }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public void AddTinyURL() { TinyURLGenerator tGenerator = new TinyURLGenerator(); TinyURLRepository tRepository = new TinyURLRepository(); TinyURLController tController = new TinyURLController(tGenerator, tRepository); tController.Request = new HttpRequestMessage { }; RequestCarrier req = new RequestCarrier() { PayLoad = "http://www.amazon.in/Clarks-Diggygrungejnr-Walnut-Leath-Leather/dp/B00C2LDGVA/ref=sr_1_87?s=shoes&ie=UTF8&qid=1478302742&sr=1-87&keywords=clarks+shoes+for+kids" }; tController.Configuration = new HttpConfiguration(); tController.Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional }); tController.RequestContext.RouteData = new HttpRouteData( route: new HttpRoute(), values: new HttpRouteValueDictionary { { "controller", "tinyURL" } }); var response = tController.GetTinyUrl(req); Assert.AreEqual(true, ((System.Web.Http.Results.JsonResult <TinyURL.api.ResponseCarrier>)response).Content.Status); }
public IHttpActionResult ForgotDoctorPassword(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null) { if (requestCarrier.PayLoad != null) { var changePasswordViewModel = WebCommon.Instance.GetObject <ChangePasswordViewModel>(requestCarrier.PayLoad); changePasswordViewModel.TanentId = requestCarrier.TanentId; string validateError = this._doctorMapper.ValidateChangePasswordOn(changePasswordViewModel); if (string.IsNullOrEmpty(validateError)) { var changePassword = this._doctorMapper.MapChangePassword(changePasswordViewModel); changePassword.CreatedBy = (int)requestCarrier.UserId.Value; changePassword.CreatedByEntity = Convert.ToInt32(requestCarrier.From); changePassword.ModifiedBy = (int)requestCarrier.UserId.Value; changePassword.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); var result = this._dataServices.DoctorService.ValidateDoctorEmail(changePassword); if (result.Success) { response = new ResponseCarrier() { Status = true, PayLoad = null, ErrorMessage = "You will receive sms with default password", TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = result.ErrorMessage, TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = validateError, TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid request.Password change failed", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid request.Operation fails", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public void TestUpdateDoctor() { IDataBaseService iDataBaseService = new DataBaseService(); DoctorService dService = new DoctorService(iDataBaseService); StaticDataServices staticDataService = new StaticDataServices(iDataBaseService); ILogger logger = new Logger(iDataBaseService); DataServices.DataServices dServ = new DataServices.DataServices(iDataBaseService); ViewModelFactory factory = new ViewModelFactory(dServ, staticDataService); DoctorMapper dMapper = new DoctorMapper(factory); DoctorController dController = new DoctorController(staticDataService, dServ, factory, dMapper, logger); dController.Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/Doctor/SaveDoctor") }; dController.Configuration = new HttpConfiguration(); dController.Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); dController.RequestContext.RouteData = new HttpRouteData( route: new HttpRoute(), values: new HttpRouteValueDictionary { { "controller", "doctor" } }); RequestCarrier req = new RequestCarrier(); req.From = "Test"; req.TanentId = -1; DoctorViewModel dvModel = new DoctorViewModel(staticDataService.GetCountry(), staticDataService.GetState(), staticDataService.GetCity(), staticDataService.GetHospital(), staticDataService.GetDegree(), staticDataService.GetSpecialization(), staticDataService.GetDesease()); dvModel.Id = 8; dvModel.Address1 = "12, DP Pharma Road"; dvModel.CityID = 1; dvModel.CreatedBy = 1; dvModel.CreatedByEntity = 1; dvModel.DoctorDegree = new List <int>(); dvModel.DoctorDesease = new List <int>(); dvModel.DoctorHospital = new List <int>(); dvModel.DoctorSpecialization = new List <int>(); dvModel.EmailAddress = "*****@*****.**"; dvModel.FirstName = "Raj"; dvModel.LastName = "Sharma"; dvModel.OtherInformation = "Heart Specilist"; dvModel.PhoneNumber = "8989889889"; dvModel.Pincode = "411014"; dvModel.ProfilePhotoID = 1; dvModel.RegistrationNumber = "RJ12123"; dvModel.TanentId = -1; //dvModel.UpdatedBy = 1; req.PayLoad = dvModel; var response = dController.SaveDoctor(req); Assert.IsNotNull(response); }
public IHttpActionResult SavePatientDetails(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { PatientDetailViewModel pViewModel = WebCommon.Instance.GetObject <PatientDetailViewModel>(requestCarrier.PayLoad); pViewModel.TanentId = requestCarrier.TanentId; string validationResponse = this._consultationMapper.ValidatePatientDetails(pViewModel); if (string.IsNullOrEmpty(validationResponse)) { var patientDetailModel = this._consultationMapper.MapPatient(pViewModel); patientDetailModel.CreatedBy = (int)requestCarrier.UserId.Value; patientDetailModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); patientDetailModel.ModifiedBy = (int)requestCarrier.UserId.Value; patientDetailModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); patientDetailModel.UserID = (int)requestCarrier.UserId.Value; if (!string.IsNullOrEmpty(patientDetailModel.FileId)) { patientDetailModel.FileId = patientDetailModel.FileId.Replace('|', ','); } else { patientDetailModel.FileId = string.Empty; } var patientResponse = _dataServices.ConsultationService.SavePatientDetails(patientDetailModel); if (patientResponse.Success) { pViewModel.Id = patientResponse.Id; response = new ResponseCarrier() { Status = true, PayLoad = pViewModel, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = patientResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult UpdateDevice(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null) { if (requestCarrier.PayLoad != null) { var doctorLogOnViewModel = WebCommon.Instance.GetObject <DoctorLogonViewModel>(requestCarrier.PayLoad); string validateError = this._doctorMapper.ValidateDoctorDevice(doctorLogOnViewModel); if (string.IsNullOrEmpty(validateError)) { doctorLogOnViewModel.TenantID = requestCarrier.TanentId; var doctorModel = this._doctorMapper.Map(doctorLogOnViewModel); doctorModel.Id = doctorLogOnViewModel.Id; var result = this._dataServices.DoctorService.UpdateDeviceId(doctorModel); if (result) { response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Error in Updating Device Id", TanentId = requestCarrier.TanentId }; } //var result = this._dataServices.UserService.UserLogOn(userModel); } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = validateError, TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid request.User Login fails", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid request.User Login fails", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public HttpResponseMessage GetSecureFileDetails(RequestCarrier requestCarrier) //currently return void need to change afterwards { if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty) { if (requestCarrier.PayLoad != null) { var secureModel = this._secureMapper.Map(WebCommon.Instance.GetObject <SecureFileViewModel>(requestCarrier.PayLoad)); secureModel.CreatedBy = (int)requestCarrier.UserId.Value; secureModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); secureModel.TenantID = requestCarrier.TanentId; string hasAccess = this._dataServices.SecureFileService.CheckSecureFileAccess(secureModel.Id, secureModel.CreatedBy, secureModel.CreatedByEntity); if (string.IsNullOrEmpty(hasAccess)) { if (secureModel.Id > 0) { SecureFileModel fileModel = new SecureFileModel() { Id = secureModel.Id }; fileModel = this._dataServices.SecureFileService.GetSecureFileDetails(fileModel); byte[] filedata = new byte[1]; string contentType = ""; if (fileModel != null) { filedata = this._dataServices.SecureFileService.DownloadFile(fileModel); contentType = MimeMapping.GetMimeMapping(fileModel.FileFullPath + fileModel.FileName); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new MemoryStream(filedata); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = fileModel.FileName, }; return(result); } } } else { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } } else { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } } else { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); }
public void TestSaveUser() { IDataBaseService iDataBaseService = new DataBaseService(); UserService uService = new UserService(iDataBaseService); StaticDataServices staticDataService = new StaticDataServices(iDataBaseService); ILogger logger = new Logger(iDataBaseService); DataServices.DataServices dServ = new DataServices.DataServices(iDataBaseService); ViewModelFactory factory = new ViewModelFactory(dServ, staticDataService); UserMapper uMapper = new UserMapper(factory); OtpMapper oMapper = new OtpMapper(factory); DoctorMapper doctorMapper = new DoctorMapper(factory); UserController uController = new UserController(staticDataService, dServ, factory, uMapper, doctorMapper, oMapper, logger); uController.Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/User/SaveUser") }; uController.Configuration = new HttpConfiguration(); uController.Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); uController.RequestContext.RouteData = new HttpRouteData( route: new HttpRoute(), values: new HttpRouteValueDictionary { { "controller", "user" } }); RequestCarrier req = new RequestCarrier(); req.From = "Test"; req.TanentId = -1; UserViewModel dvModel = new UserViewModel(staticDataService.GetCountry(), staticDataService.GetState(), staticDataService.GetCity()); dvModel.Id = 6; dvModel.Email = "*****@*****.**"; dvModel.Password = "******"; dvModel.FirstName = "Shubham"; dvModel.LastName = "Joshi"; dvModel.CreatedByEntity = 1; dvModel.PhoneNumber = "8968574635"; dvModel.IsPhoneNoVerified = false; dvModel.IsDeleted = false; dvModel.TanentId = -1; dvModel.CreatedBy = 1; //dvModel.UpdatedBy = 1; req.PayLoad = dvModel; var response = uController.SaveUser(req); Assert.IsNotNull(response); }
public IHttpActionResult SaveDoctor(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue) { DoctorViewModel dViewModel = WebCommon.Instance.GetObject <DoctorViewModel>(requestCarrier.PayLoad); string validationResponse = this._doctorMapper.ValidateDoctor(dViewModel); if (string.IsNullOrEmpty(validationResponse)) { dViewModel.TanentId = requestCarrier.TanentId; var doctorModel = this._doctorMapper.Map(dViewModel); doctorModel.CreatedBy = (int)requestCarrier.UserId.Value; doctorModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); doctorModel.ModifiedBy = (int)requestCarrier.UserId.Value; doctorModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); doctorModel.Password = ConfigurationManager.DefaultPassword; string encryptedPassword = Common.SecurityManager.EncryptText(doctorModel.Password); doctorModel.HashPassword = encryptedPassword; var userResponse = _dataServices.DoctorService.SaveDoctor(doctorModel); if (userResponse.Success) { dViewModel.Id = userResponse.Id; dViewModel.Password = string.Empty; response = new ResponseCarrier() { Status = true, PayLoad = dViewModel, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = userResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult Register(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null) { var userViewModel = WebCommon.Instance.GetObject <UserViewModel>(requestCarrier.PayLoad); string validateError = this._userMapper.ValidateUserRegistration(userViewModel); if (string.IsNullOrEmpty(validateError)) { userViewModel.TanentId = requestCarrier.TanentId; userViewModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); userViewModel.ModifiedEntity = Convert.ToInt32(requestCarrier.From); string encryptedPassword = Common.SecurityManager.EncryptText(userViewModel.Password); var userModel = this._userMapper.Map(userViewModel); userModel.HashPassword = encryptedPassword; var result = this._dataServices.UserService.RegisterUser(userModel); if (result.Success) { //userViewModel.Id = result.Id response = new ResponseCarrier() { Status = true, PayLoad = null, ErrorMessage = "Registration Successful.", TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid Request. Users Id not provided.", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = validateError, TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid Request. User Registration can not be processed.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetHospitalDetail(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { if (requestCarrier.PayLoad != null) { long id = 0; if (long.TryParse(requestCarrier.PayLoad.ToString(), out id) && id > 0) { HospitalModel hospital = _staticDataServices.GetHospitalDetail(id); var result = _doctorMapper.MapHospitalDetail(hospital); response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else if (id == -1) { HospitalModel hospital = new HospitalModel(); var result = _doctorMapper.MapHospitalDetail(hospital); response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid Id supplied", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid Id supplied", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Error in fetching Hospital", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetUser(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue) { if (requestCarrier.PayLoad != null) { var userViewModel = WebCommon.Instance.GetObject <UserViewModel>(requestCarrier.PayLoad); // userViewModel = (UserViewModel)requestCarrier.PayLoad; if (userViewModel != null && userViewModel.Id > 0) { userViewModel.TanentId = requestCarrier.TanentId; var userModel = this._dataServices.UserService.GetUser(userViewModel.Id, userViewModel.TanentId); userViewModel = this._userMapper.Map(userModel); response = new ResponseCarrier() { Status = true, PayLoad = userViewModel, ErrorMessage = string.Empty }; } else { userViewModel = _viewModelFactory.CreateUserViewModel(); response = new ResponseCarrier() { Status = true, PayLoad = userViewModel, ErrorMessage = string.Empty }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid Request. Users Id not provided.", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult SaveDesease(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue) { DeseasesViewModel dViewModel = WebCommon.Instance.GetObject <DeseasesViewModel>(requestCarrier.PayLoad); string validationResponse = this._doctorMapper.ValidateDesease(dViewModel); if (string.IsNullOrEmpty(validationResponse)) { dViewModel.TanentId = requestCarrier.TanentId; var deseaseModel = this._doctorMapper.MapDoctorDesease(dViewModel); deseaseModel.CreatedBy = (int)requestCarrier.UserId.Value; deseaseModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); deseaseModel.ModifiedBy = (int)requestCarrier.UserId.Value; deseaseModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); var userResponse = _staticDataServices.SaveDesease(deseaseModel); if (userResponse.Success) { deseaseModel.LongId = userResponse.LongId; response = new ResponseCarrier() { Status = true, PayLoad = deseaseModel, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = userResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult SaveCaseNote(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { CaseNoteViewModel cViewModel = WebCommon.Instance.GetObject <CaseNoteViewModel>(requestCarrier.PayLoad); cViewModel.TanentId = requestCarrier.TanentId; string validationResponse = this._consultationMapper.ValidateCaseNote(cViewModel); if (string.IsNullOrEmpty(validationResponse)) { var caseNoteModel = this._consultationMapper.MapCaseNote(cViewModel); caseNoteModel.CreatedBy = (int)requestCarrier.UserId.Value; caseNoteModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); caseNoteModel.ModifiedBy = (int)requestCarrier.UserId.Value; caseNoteModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); var caseNoteResponse = _dataServices.ConsultationService.SaveCaseNote(caseNoteModel); if (caseNoteResponse.Success) { cViewModel.Id = caseNoteResponse.Id; response = new ResponseCarrier() { Status = true, PayLoad = cViewModel, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = caseNoteResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetDoctor(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue) { if (requestCarrier.PayLoad != null) { var doctorViewModel = WebCommon.Instance.GetObject <DoctorViewModel>(requestCarrier.PayLoad); if (doctorViewModel != null && doctorViewModel.Id > 0) { var doctorModel = this._dataServices.DoctorService.GetDoctor(doctorViewModel.Id, requestCarrier.TanentId); _staticDataServices.Start(); doctorViewModel = this._doctorMapper.Map(doctorModel); response = new ResponseCarrier() { Status = true, PayLoad = doctorViewModel, ErrorMessage = string.Empty }; } else { doctorViewModel = _viewModelFactory.CreateDoctorViewModel(); response = new ResponseCarrier() { Status = true, PayLoad = doctorViewModel, ErrorMessage = string.Empty }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Invalid Request. Doctor Id not provided.", TanentId = requestCarrier.TanentId }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId(doctorId) not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult SaveUser(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue) { var userModel = this._userMapper.Map(WebCommon.Instance.GetObject <UserViewModel>(requestCarrier.PayLoad)); userModel.CreatedBy = (int)requestCarrier.UserId.Value; userModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); userModel.ModifiedBy = (int)requestCarrier.UserId.Value; userModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From); userModel.TenantID = requestCarrier.TanentId; string validationResponse = this._userMapper.ValidateUser(userModel); if (string.IsNullOrEmpty(validationResponse)) { var userResponse = _dataServices.UserService.SaveUser(userModel); if (userResponse.Success) { response = new ResponseCarrier() { Status = true, TanentId = requestCarrier.TanentId, PayLoad = userResponse }; } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = userResponse.ErrorMessage }; } } else { response = new ResponseCarrier() { Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UrerId not provided (in case of user id please provide -1).", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetOTP(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.PayLoad != null && requestCarrier.UserId.HasValue) { var otpModel = this._otpMapper.Map(WebCommon.Instance.GetObject <otpViewmodel>(requestCarrier.PayLoad)); otpModel.CreatedBy = (int)requestCarrier.UserId.Value; otpModel.UserId = (int)requestCarrier.UserId.Value; otpModel.CreatedByEntity = Convert.ToInt32(requestCarrier.From); otpModel.otpCode = WebCommon.Instance.GetOTP(); this._dataServices.UserService.SaveOTP(otpModel); UserModel userInfo = null; if (otpModel.Success) { if (WebCommon.NotificationEnabled) { userInfo = this._dataServices.UserService.GetUserByPhoneNo(otpModel.otpMobileNo, requestCarrier.TanentId); userInfo.From = Convert.ToInt16(requestCarrier.From); if (userInfo.Success) { List <object> additionalParameters = new List <object>(); additionalParameters.Add(userInfo.Email); additionalParameters.Add(userInfo.PhoneNumber); additionalParameters.Add(otpModel.otpCode); additionalParameters.Add(userInfo.DeviceId); NotificationClient.Instance.SendMessage(null, ImTech.Notification.Messages.MessageType.User_OTP, additionalParameters); } } } response = new ResponseCarrier() { Status = userInfo.Success, PayLoad = null, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetTinyUrl(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.PayLoad != null) { string longUrl = requestCarrier.PayLoad.ToString(); string shortenURL = _tinyUrlGenerator.GetTinyURL(longUrl); if (_tinyURLRepository.IsExist(shortenURL)) { shortenURL = _tinyUrlGenerator.GetTinyURL(longUrl); } if (!string.IsNullOrEmpty(shortenURL)) { URLMapping mapping = new URLMapping() { TinyUrl = shortenURL, Url = longUrl }; _tinyURLRepository.AddShortenedURLMapping(mapping); response = new ResponseCarrier() { Status = true, PayLoad = shortenURL, ErrorMessage = string.Empty }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Request URL not provided." }; } } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Request URL not provided." }; } return(Json(response)); }
public void TestGetUser() { IDataBaseService iDataBaseService = new DataBaseService(); UserService uService = new UserService(iDataBaseService); StaticDataServices staticDataService = new StaticDataServices(iDataBaseService); ILogger logger = new Logger(iDataBaseService); DataServices.DataServices dServ = new DataServices.DataServices(iDataBaseService); ViewModelFactory factory = new ViewModelFactory(dServ, staticDataService); UserMapper uMapper = new UserMapper(factory); OtpMapper oMapper = new OtpMapper(factory); DoctorMapper doctorMapper = new DoctorMapper(factory); UserController uController = new UserController(staticDataService, dServ, factory, uMapper, doctorMapper, oMapper, logger); uController.Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost/User/GetUser") }; uController.Configuration = new HttpConfiguration(); uController.Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); uController.RequestContext.RouteData = new HttpRouteData( route: new HttpRoute(), values: new HttpRouteValueDictionary { { "controller", "user" } }); RequestCarrier req = new RequestCarrier(); req.From = "Test"; req.TanentId = -1; UserViewModel uvModel = new UserViewModel(staticDataService.GetCountry(), staticDataService.GetState(), staticDataService.GetCity()); uvModel.Id = 3; req.PayLoad = uvModel; var response = uController.GetUser(req); }
public async Task <ActionResult> MyTinyUrl(string id) { RequestCarrier req = new RequestCarrier() { PayLoad = id }; WebApiClient wClient = new WebApiClient(); HttpResponseMessage responseMessage = await wClient.PostAsyncMyTinyURL(req); if (responseMessage.IsSuccessStatusCode) { var responseData = responseMessage.Content.ReadAsStringAsync().Result; var data = JsonConvert.DeserializeObject <ResponseCarrier>(responseData); if (data != null && data.PayLoad != null) { string redirectUrl = data.PayLoad.ToString(); return(Redirect(redirectUrl)); } } return(RedirectToAction("Index", "Home")); }
public IHttpActionResult GetDoctorList([FromBody] RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty) { var result = _doctorMapper.Map(_dataServices.DoctorService.GetDoctorList(-1, requestCarrier.TanentId)); response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetHospitals(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { IEnumerable <HospitalModel> hospitals = _staticDataServices.GetHospitalorHospitalsListDetail(); var result = _doctorMapper.MapDoctorHospital(hospitals); response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Error in fetching Hospital", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetDeseases(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0) { IEnumerable <DeseaseModel> deseasesModel = _staticDataServices.GetDeseaseModelCollection(); var result = _doctorMapper.MapDoctorDesease(deseasesModel); response = new ResponseCarrier() { Status = true, PayLoad = result, ErrorMessage = string.Empty, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "Error in fetching Degree", TanentId = requestCarrier.TanentId }; } return(Json(response)); }
public IHttpActionResult GetAddUser(RequestCarrier requestCarrier) { ResponseCarrier response; if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue) { var userVM = this._userMapper.CreateViewModel(); userVM.TanentId = requestCarrier.TanentId; response = new ResponseCarrier() { Status = true, PayLoad = userVM, TanentId = requestCarrier.TanentId }; } else { response = new ResponseCarrier() { Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId }; } return(Json(response)); }