public ResponseModel AddRequestForTractorPrice(RequestForTractorPriceModel request) { IAuthentication _authrepository = new DataAccess.Authentication.Authentication(); IMasterTablesDataAccess _repository = new MasterTablesDataAccess(); int response = 0; response = _repository.AddRequestForQuotation(request); string Status = "0"; ResponseModel model = new ResponseModel(); if (response > 0) { model.Status = response.ToString(); model.Message = "Request For Quotation Raised Successfully."; UserModel user = new UserModel(); user = _authrepository.GetUserDetails(request.UserId); var lfd = _repository.GetLookingForDetailsById(request.LookingForDetailsId).LookingForDetails; var models = _repository.GetModelById(request.ModelId).Model; string msg = user.FullName + " is Looking for " + lfd + " of " + models; Notification.SendNotification(request.UserId, WebConfigurationManager.AppSettings["LKF"], msg); } else { model.Status = "0"; } return(model); }
public LoginResponseObject ValidateUser(LoginRequestObject viewmodel) { LoginResponseObject objentity = new LoginResponseObject(); AppResponseView objApp = new AppResponseView(); LoginResponseModel objLoginResp = new LoginResponseModel(); IAuthentication _repository = new DataAccess.Authentication.Authentication(); objLoginResp = _repository.ValidateUser(viewmodel.UserRequest); objentity.ResultObject = objLoginResp; if (objentity.ResultObject.Status == 1) { if (objentity.ResultObject.IsOTPverified == false) { objentity.ResultObject.Status = 0; objentity.ResultObject.Message = "OTP Not Verified"; } else { objentity.ResultObject.Status = 1; objentity.ResultObject.Message = "Success"; objentity.ResultObject.user = _repository.GetUserDetails(objentity.ResultObject.UserId); } //string OTP = GenerateNewOTP(); //objLoginResp.OTP = OTP; //objentity.ResultObject = objLoginResp; //SMSService.SendSms(viewmodel.UserRequest.UserName, ("Login OTP " + objentity.ResultObject.OTP)); } else { objentity.ResultObject.Message = "Invalid Credentials"; } return(objentity); }
public objRegisterResponseModel RegisterUser(objRegisterRequestModel requestModel) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel objResponse = new objRegisterResponseModel(); int Id = _repository.AddUser(requestModel.objUser); if (Id > 0) { UserModel user = new UserModel(); user.Id = Id; string OTP = GenerateNewOTP(); user.OTP = OTP; user.PhoneNo = requestModel.objUser.PhoneNo; user.FullName = requestModel.objUser.FullName; user.EmailId = requestModel.objUser.EmailId; objResponse.user = user; SMSService.SendSms(requestModel.objUser.PhoneNo, ("Login OTP " + user.OTP), user.OTP); AppResponseView response = new AppResponseView(); response.Message = "User Registered Successfully"; response.Status = 1; objResponse.Response = response; _repository.UpdateRegisterOTPCountForUser(requestModel.objUser.PhoneNo, true); } else { AppResponseView response = new AppResponseView(); response.Message = "User already Registered"; response.Status = 0; objResponse.Response = response; } return(objResponse); }
public LoginResponseModel ResendOTP(LoginRequestModel requestModel) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); LoginResponseModel objResponse = new LoginResponseModel(); int Result = _repository.CheckPhoneNoExists(requestModel.UserName); if (Result > 0) { objResponse = _repository.GetRegisterOTPCountForUser(requestModel.UserName); DateTime Currentdate = DateTime.Now; DateTime OTPsentdate = Convert.ToDateTime(objResponse.RegisterOTPSentDate); int reslt = 0; if (objResponse.RegisterOTPSentDate == DateTime.MinValue) { string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; objResponse.Message = "You have Another 2 chance to send OTP"; SMSService.SendSms(requestModel.UserName, (objResponse.OTP), objResponse.OTP); _repository.UpdateRegisterOTPCountForUser(requestModel.UserName, true); } else { reslt = DateTime.Compare(Currentdate.Date, OTPsentdate.Date); if (reslt != 0) { string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; objResponse.RegisterOTPSentCount = 1; objResponse.Message = "You have Another 2 chance to send OTP"; SMSService.SendSms(requestModel.UserName, (objResponse.OTP), objResponse.OTP); _repository.UpdateRegisterOTPCountForUser(requestModel.UserName, true); } else if (reslt == 0 && objResponse.RegisterOTPSentCount < 3) { string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; objResponse.RegisterOTPSentCount = objResponse.RegisterOTPSentCount + 1; int balance = 3 - Convert.ToInt32(objResponse.RegisterOTPSentCount); objResponse.Message = "You have another " + balance + " chance to send OTP"; SMSService.SendSms(requestModel.UserName, (objResponse.OTP), objResponse.OTP); _repository.UpdateRegisterOTPCountForUser(requestModel.UserName, false); } else if (reslt == 0 && objResponse.RegisterOTPSentCount >= 3) { objResponse.Status = 2; objResponse.RegisterOTPSentCount = 3; objResponse.Message = "You have Exceeded the limit of resending OTP"; } } } else { objResponse.Status = 0; } return(objResponse); }
public static FCMPushNotification SendNotification(int userId, string notificationId, string message) { IMasterTablesDataAccess _repository = new MasterTablesDataAccess(); IAuthentication _authrepository = new DataAccess.Authentication.Authentication(); UserModel user = new UserModel(); user = _authrepository.GetUserDetails(userId); string DeviceId = user.DeviceId.ToString(); List <string> NotificationsSubscribed = GetList(user.NotificationTypeId); FCMPushNotification pushNotification = new FCMPushNotification(); if (NotificationsSubscribed.Contains(notificationId.ToString())) { NotificationsModel response = new NotificationsModel(); NotificationModel notificationModel = new NotificationModel(); response.NotificationMasterList = _repository.GetNotificationMaster(); var notification = response.NotificationMasterList.Where(x => x.NotificationID == Convert.ToInt32(notificationId)).FirstOrDefault(); Notification objNotification = new Notification(); if (notification.ToAll) { pushNotification = objNotification.SendNotificationToTopic(notification.NotificationCode, notification.NotificationAction, message); } else { pushNotification = objNotification.SendNotificationToRegisteredUser(DeviceId, notification.NotificationAction, message); } notificationModel.NotificationText = message; notificationModel.ToAll = notification.ToAll; notificationModel.ToUserId = userId; notificationModel.CreatedBy = userId; _repository.AddNotification(notificationModel); } return(pushNotification); }
public objRegisterResponseModel UpdateUserProfile() { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel response = new objRegisterResponseModel(); AppResponseView appResponse = new AppResponseView(); //////////////////////////////////////////// var httpRequest = HttpContext.Current.Request; HttpPostedFile postedFile = null; if (httpRequest.Files.Count > 0) { postedFile = httpRequest.Files[0]; } //convert the posted file stream a to memory stream //System.IO.MemoryStream target = new System.IO.MemoryStream(); //postedFile.InputStream.CopyTo(target); //the following static function is a function I built which accepts the amazon file key and also the object that will be uploaded to S3, in this case, a MemoryStream object UserModel request = new UserModel(); request.Id = int.Parse(httpRequest.Form["UserId"]); request.FullName = httpRequest.Form["FullName"] == ""?null: httpRequest.Form["FullName"]; request.PhoneNo = httpRequest.Form["PhoneNo"] == "" ? null : httpRequest.Form["PhoneNo"]; request.EmailId = httpRequest.Form["EmailId"] == "" ? null : httpRequest.Form["EmailId"]; request.Password = httpRequest.Form["Password"] == "" ? null : httpRequest.Form["Password"]; if (postedFile != null) { AmazonS3Uploader service = new AmazonS3Uploader(); request.ProfilePic = service.UploadFile("FarmPeProfilePics/" + request.Id + postedFile.FileName, new HttpPostedFileWrapper(postedFile)); } ////////////////////////////////////////////// appResponse.Status = _repository.UpdateUserProfile(request); response.Response = appResponse; return(response); }
public objRegisterResponseModel GetCustomers() { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel response = new objRegisterResponseModel(); response.Customers = _repository.GetCustomersList(); return(response); }
public objRegisterResponseModel GetAccessContentByLangCode(objRegisterRequestModel request) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel response = new objRegisterResponseModel(); response.AccessContent = _repository.GetAccessContentByLangCode(request.objAccess.LangCode, request.objAccess.Type); return(response); }
public objRegisterResponseModel ValidateRefferalCode(objRegisterRequestModel request) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel response = new objRegisterResponseModel(); response.user = _repository.ValidateRefferalCode(request.objUser.RefferalCode); return(response); }
public objRegisterResponseModel GetUserDetails(objRegisterRequestModel request) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel response = new objRegisterResponseModel(); response.user = _repository.GetUserDetails(request.objUser.Id); return(response); }
public objRegisterResponseModel UpdateUserPassword(objRegisterRequestModel request) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); objRegisterResponseModel response = new objRegisterResponseModel(); AppResponseView appResponse = new AppResponseView(); appResponse.Status = _repository.UpdateUserPassword(request.objUser); response.Response = appResponse; return(response); }
public LoginResponseModel SendOTPForLogin(LoginRequestModel requestModel) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); LoginResponseModel objResponse = new LoginResponseModel(); string OTP = GenerateNewOTP(); objResponse.OTP = OTP; objResponse.Status = 1; string Message = "OTP for Login to Xohri " + objResponse.OTP; SMSService.SendSms(requestModel.UserName, Message, objResponse.OTP); return(objResponse); }
public LoginResponseObject ChangePasswordNew(LoginRequestObject Request) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); int result = _repository.ChangePassword(Request.UserRequest); LoginResponseObject response = new LoginResponseObject(); if (result == 1) { LoginResponseModel model = new LoginResponseModel(); model.Message = "Password Updated Successfully"; model.Status = 1; response.ResultObject = model; } return(response); }
public objRegisterResponseModel VerifyOTPNewUser(objRegisterRequestModel Request) { IAuthentication _repository = new DataAccess.Authentication.Authentication(); int result = _repository.VerifyOTPofNewUser(Request.objUser); objRegisterResponseModel response = new objRegisterResponseModel(); if (result > 0) { AppResponseView objresponse = new AppResponseView(); objresponse.Message = "User Registered Successfully"; response.user = _repository.GetUserDetails(result); response.Response = objresponse; } return(response); }
public ResponseModel AddUpdateFarms()//FarmsModel request, HttpPostedFile farmimage, HttpPostedFile coverimage) { IAuthentication _authrepository = new DataAccess.Authentication.Authentication(); IMasterTablesDataAccess _repository = new MasterTablesDataAccess(); int response = 0; var httpRequest = HttpContext.Current.Request; FarmsModel objFarmsModel = new FarmsModel(); FarmsModel request = new FarmsModel(); request = JsonConvert.DeserializeObject <FarmsModel>(httpRequest.Form["farmsdetail"]); HttpPostedFile farmimage = httpRequest.Files["farmimage"]; if (farmimage != null) { AmazonS3Uploader service = new AmazonS3Uploader(); request.FarmImages = service.UploadFile("FarmImages/" + request.MobileNumber + farmimage.FileName, new HttpPostedFileWrapper(farmimage)); } HttpPostedFile coverimage = httpRequest.Files["coverimage"]; if (coverimage != null) { AmazonS3Uploader service = new AmazonS3Uploader(); request.CoverPhoto = service.UploadFile("FarmCoverPhotos/" + request.MobileNumber + coverimage.FileName, new HttpPostedFileWrapper(coverimage)); } response = _repository.AddUpdateFarms(request); string Status = "0"; ResponseModel model = new ResponseModel(); if (response > 0) { model.Status = response.ToString(); model.Message = "Farm has been added/updated successfully."; UserModel user = new UserModel(); user = _authrepository.GetUserDetails(request.CreatedBy); //var lfd = _repository.GetLookingForDetailsById(request.LookingForDetailsId).LookingForDetails; //var models = _repository.GetModelById(request.ModelId).Model; //string msg = user.FullName + " is Looking for " + lfd + " of " + models; //Notification.SendNotification(request.UserId, WebConfigurationManager.AppSettings["LKF"], msg); } else { model.Status = "0"; } return(model); }