public bool SendNotiAllDevices(int user_id, string title, string body, int badge) { try { Notification notification; List <string> devices = new UserRepository.UserRepository(language).GetUserDevices(user_id); for (int i = 0; i < devices.Count; i++) { notification = new Notification(); notification.title = title; notification.body = body; notification.badge = badge; notification.to = devices[i]; if (SendNotification(notification)) { continue; } else { new Response(false, "Notification Not Sent", "Notification Not Sent : Device Id : " + devices[i] + " :: , User_id : " + user_id); } } return(true); } catch (Exception ex) { new Response(false, "Notification Not Sent", "Notification Not Sent : User_id : " + user_id + " exception : " + ex); return(false); } }
public Response ChangePhoneNumber(string phonenumber, string user_id) { try { int newPhoneUser = new UserRepository.UserRepository(language).GetUserIdByPhoneNumber(phonenumber); if (newPhoneUser > 0 && newPhoneUser != Convert.ToInt32(user_id)) { return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.PHONE_ANOTHER_USER))); } if (new ServicesRepository(language).ChangePhoneNumber(phonenumber, Convert.ToInt32(user_id))) { return(new Response(true, Messages.GetMessage(language, TypeM.SERVICE, serviceM.SERVICE_CHANGE_PHONE))); } else { throw new UpdateException(language); } } catch (UpdateException UpdateException) { return(new Response(false, UpdateException.RespMessage, UpdateException.ErrorMessage)); } catch (Exception ex) { return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR), ex.Message.ToString())); } }
public ExaminationSurgeryRepository(TreatmentRepository treatmentRepository, MedicalRecordRepository.MedicalRecordRepository medicalRecordRepository, UserRepository.UserRepository doctorRepository, Stream <ExaminationSurgery> stream) : base(stream, "Examination") { this.treatmentRepository = treatmentRepository; this.medicalRecordRepository = medicalRecordRepository; this.doctorRepository = doctorRepository; }
private bool Validate(string token, string username) { bool exists = new UserRepository.UserRepository().GetUser(username) != null; // if (!exists) return Request.CreateResponse(HttpStatusCode.NotFound, // "The user was not found."); string tokenUsername = TokenManager.ValidateToken(token); if (!username.Equals(tokenUsername)) { //return Request.CreateResponse(HttpStatusCode.OK); // return Request.CreateResponse(HttpStatusCode.BadRequest); return(false); } return(true); }
public ActionResult <Response> ResetPassword([FromQuery(Name = "lang")] string lang, [FromBody] GetCriteria getCriteria) { Response resp = new UserService(lang).ResetPassword(getCriteria.phoneNumber, getCriteria.password); //check AccessToken if (resp.status) { int userType = new UserRepository.UserRepository(lang).GetUserUserTypeByPhone(getCriteria.phoneNumber); resp.innerData = new UserService(lang).GetProfileByPhone(getCriteria.phoneNumber, userType, lang).innerData; } return(resp); }
public Response GetWorkshopBills(string accessToken) { try { int workshop_id = new UserRepository.UserRepository(language).GetSupplierIdByAccessToken(accessToken); List <Bill> wrokshopStats = new StatRepository(language).GetWorkshopBills(workshop_id); return(new Response(true, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.DATAGOT), wrokshopStats)); } catch (EmptyViewException EmptyViewException) { return(new Response(false, EmptyViewException.RespMessage, EmptyViewException.ErrorMessage)); } catch (Exception ex) { return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR), ex.Message.ToString())); } }
public HttpResponseMessage Validate(string token, string username) { bool exists = new UserRepository.UserRepository().GetUser(username) != null; if (!exists) { return(Request.CreateResponse(HttpStatusCode.NotFound, "The user was not found.")); } string tokenUsername = TokenManager.ValidateToken(token); if (username.Equals(tokenUsername)) { return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public Response GetWorkshopBills(GetCriteria getCriteria) { try { int workshop_id = new UserRepository.UserRepository(language).GetSupplierIdByAccessToken(getCriteria.accessToken); List <UserBill> userBills = new ServicesRepository(language).GetWorkshopBills(workshop_id); return(new Response(true, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.DATAGOT), userBills)); } catch (EmptyViewException EmptyViewException) { return(new Response(true, EmptyViewException.RespMessage, EmptyViewException, new List <string>())); } catch (Exception ex) { return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR), ex, new List <string>())); } }
public HttpResponseMessage Login(User user) { User u = new UserRepository.UserRepository().GetUser(user.Username); if (u == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "The user was not found.")); } bool credentials = u.Password.Equals(user.Password); if (!credentials) { return(Request.CreateResponse(HttpStatusCode.Forbidden, "The username/password combination was wrong.")); } return(Request.CreateResponse(HttpStatusCode.OK, TokenManager.GenerateToken(user.Username))); }
public Response ChangePassword(GetCriteria getCriteria) { try { bool isPasswordCorrect; int user_id = new UserRepository.UserRepository(language).GetUserIdByAccessToken(getCriteria.accessToken); try { isPasswordCorrect = PasswordHash.ValidatePassword(getCriteria.oldPassword, new ServicesRepository(language).ComparePassword(getCriteria.oldPassword, user_id)); }catch (EmptyViewException EmptyViewException) { return(new Response(false, Messages.GetMessage(language, TypeM.SERVICE, serviceM.SERVICE_COMPARE_PASSNOTFOUND))); } if (!isPasswordCorrect) { return(new Response(false, Messages.GetMessage(language, TypeM.SERVICE, serviceM.SERVICE_COMPARE_PASSNOTFOUND))); } if (new ServicesRepository(language).ChangePassword(PasswordHash.CreateHash(getCriteria.password), user_id)) { return(new Response(true, Messages.GetMessage(language, TypeM.SERVICE, serviceM.SERVICE_CHANGE_PASSWORD))); } else { throw new UpdateException(language); } } catch (InsertException InsertException) { return(new Response(false, InsertException.RespMessage, InsertException.ErrorMessage)); } catch (Exception ex) { return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR), ex.Message.ToString())); } }
public Response CreateService(serviceRequest serviceRequest) { try { int user_id = new UserRepository.UserRepository(language).GetUserIdByAccessToken(serviceRequest.accessToken); if (new ServicesRepository(language).InsertService(serviceRequest, user_id)) { return(new Response(true, Messages.GetMessage(language, TypeM.SERVICE, serviceM.SERVICE_CREATE))); } else { throw new InsertException(language); } } catch (InsertException InsertException) { return(new Response(false, InsertException.RespMessage, InsertException.ErrorMessage)); } catch (Exception ex) { return(new Response(false, Messages.GetMessage(language, TypeM.DEFAULT, defaultM.UNEXPERROR), ex.Message.ToString())); } }