Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public void SendSms(string phone, string message, string mask, string smsSender)
 {
     try
     {
         smsapi = new SMSService();
         smsapi.SendSms(phone, message, mask, smsSender, "EMEMU", "T3rr1613");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
            public async Task DefaultMessageAsync(string phoneNr, [Remainder] string message)
            {
                SMSService smsService = new SMSService($"https://");

                // Old method..
                //Regex regex = new Regex(@"^\d$");

                if ((phoneNr != "" || phoneNr.Length != 0) && (message != "" || message.Length != 0))
                {
                    // Old method..
                    //Regex isMatchedReg = new Regex("^[0-9]+$");

                    if (Regex.IsMatch(phoneNr, "^[0-9]*$"))
                    {
                        smsService.SendSms(phoneNr, message);
                        await Context.User.SendMessageAsync($"Successfully Sent message to {phoneNr} with message: {message} - by {Context.User.Username}");
                    }
                    else
                    {
                        await ReplyAsync($"Number containing invalid characters.");
                    }
                }
                return;
            }
Esempio n. 6
0
        public ActionResult AddPatient(PatientModel model)
        {
            #region temp code this must be removed
            //PatientPaymentServices.AddPayType(new PayType
            //{
            //    Description = "Card"
            //});
            //PatientPaymentServices.AddPayType(new PayType
            //{
            //    Description = "Cash"
            //});
            #endregion
            #region testing code should be delete
            //var model=new PatientModel(){
            //    BranchId=1,
            //    Name="firstTestPatient",
            //    Email="*****@*****.**",
            //    GenderId=1,
            //    DateofBirth=DateTime.Now,
            //    PhoneNumber="987987697",
            //    ReferredId=-1
            //};
            #endregion

            try
            {
                if (model.PatientTestIds.Count > 0)
                {
                    int UserId = Convert.ToInt32(Session["loginuser"].ToString());
                    var branch = UserServices.GetUserBranch(UserId);
                    model.BranchId = branch.Id;
                    model.Age      = (DateTime.Now.Year - model.DateofBirth.Year).ToString();

                    PatientServices.Add(model);
                    List <TestSubCategoryModel> selectedTests = new List <TestSubCategoryModel>();
                    double netAmount = 0;
                    foreach (var TestId in model.PatientTestIds)
                    {
                        PatientTestService.Add(new PatientTest
                        {
                            PatientId         = model.Id,
                            TestSubcategoryId = TestId
                        });
                        var test = TestSubCategoryServices.getById(TestId);
                        selectedTests.Add(new TestSubCategoryModel {
                            Rate = test.Rate,
                            TestSubcategoryName = test.TestSubcategoryName,
                            Unit = test.Unit
                        });

                        netAmount = netAmount + test.Rate;
                    }

                    if (model.Discount > 0)
                    {
                        netAmount = netAmount - model.Discount;
                    }

                    PatientPaymentServices.Add(new Payment
                    {
                        PatientId   = model.Id,
                        PatientName = model.Name,
                        PaidAmount  = model.PaidAmount,
                        Discount    = model.Discount,
                        NetAmount   = netAmount,
                        Balance     = netAmount - model.PaidAmount,
                        PayTypeId   = model.PayId
                    });

                    var gender = GenderServices.GetById(model.GenderId);

                    model.Genders.Add(new SelectListItem
                    {
                        Text = gender.GenderDescription
                    });

                    var referdoctor = ReferDoctorsServices.GetReferDoctorById(model.ReferredId);

                    model.ReferredDoctors.Add(new SelectListItem
                    {
                        Text = referdoctor.ReferredDoctorName
                    });
                    var branchContact = BranchServices.GetBranchContact(branch.Id);

                    SmsServices.SendSms(model.PhoneNumber, model.Id);
                    model.GenderDesc = gender.GenderDescription;
                    var ReciptModels = new ReciptModel()
                    {
                        Branch = new BranchModel
                        {
                            Address = branch.BranchAddress,
                            Contact = branchContact.BranchContactNo,
                            Name    = branch.BranchName
                        },
                        PatientDetails = model,
                        PatientTests   = selectedTests
                    };
                    ReciptModels.LogedInUser = Session["loginusername"].ToString();
                    // var pdfDocModel = GeneratePatientRecipt(model, gender, selectedTests, branch, branchContact);

                    return(Json(ReciptModels, JsonRequestBehavior.AllowGet));
                }
                return(Json("Please assign tests to patients", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }