Exemplo n.º 1
0
 public bool UpdateSecretToken(string MobileNo, string Token)
 {
     using (var db = new ObickeEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 var IsAlreadyExists = db.MobileOtps.Where(a => a.MobileNo == MobileNo).FirstOrDefault();
                 if (IsAlreadyExists != null)
                 {
                     IsAlreadyExists.SecretToken      = Token;
                     IsAlreadyExists.ModifiedDateTime = DateTime.Now;
                     db.SaveChanges();
                 }
                 transaction.Commit();
                 return(true);
             }
             catch (Exception Ex)
             {
                 string msg = Ex.ToString();
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
Exemplo n.º 2
0
 public string RemoveCart(BikeInfoById bikeInfoById)
 {
     using (var db = new ObickeEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 var isExists = db.AddToCarts.Where(a => a.SecretToken == bikeInfoById.SecretToken && a.BikeId == bikeInfoById.BikeId).FirstOrDefault();
                 if (isExists != null)
                 {
                     db.AddToCarts.Remove(isExists);
                     db.SaveChanges();
                     transaction.Commit();
                     return("Success");
                 }
                 else
                 {
                     return("No record found");
                 }
             }
             catch (Exception Ex)
             {
                 string msg = Ex.ToString();
                 transaction.Rollback();
                 return(Ex.Message);
             }
         }
     }
 }
Exemplo n.º 3
0
        public BikeInformation PostBikeInfoDetails(CoreBikeInformation BikeInformationsmodel)
        {
            using (var db = new ObickeEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        BikeInformation data = new BikeInformation()
                        {
                            BikeBrand            = BikeInformationsmodel.BikeBrand,
                            BikeModel            = Convert.ToDecimal(BikeInformationsmodel.BikeModel),
                            BikeRegistrationYear = BikeInformationsmodel.BikeRegistrationYear,
                            BikeKmDriven         = BikeInformationsmodel.BikeKmDriven,
                            BikeDescription      = BikeInformationsmodel.BikeDescription,
                            BikeOwnerName        = BikeInformationsmodel.BikeOwnerName,
                            BikePrice            = BikeInformationsmodel.BikePrice,
                            IsActive             = true,
                            IsDelete             = false
                        };
                        db.BikeInformations.Add(data);
                        db.SaveChanges();
                        foreach (var obj in BikeInformationsmodel.Imagepath)
                        {
                            ImageDetail imgdeatails = new ImageDetail()
                            {
                                BikeId  = data.BikeId,
                                ImgPath = obj.Imagepath
                            };
                            db.ImageDetails.Add(imgdeatails);
                        }
                        db.SaveChanges();
                        transaction.Commit();

                        return(data);
                    }
                    catch (Exception Ex)
                    {
                        string msg = Ex.ToString();
                        transaction.Rollback();

                        return(null);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public bool SaveUpdateMobileNoWithOtp(MobileOtpDetails mobileOtpDetails)
 {
     using (var db = new ObickeEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 var IsAlreadyExists = db.MobileOtps.Where(a => a.MobileNo == mobileOtpDetails.MobileNo).FirstOrDefault();
                 if (IsAlreadyExists != null)
                 {
                     IsAlreadyExists.OTP              = mobileOtpDetails.OTP;
                     IsAlreadyExists.OTPSendCount     = IsAlreadyExists.OTPSendCount + 1;
                     IsAlreadyExists.ModifiedDateTime = DateTime.Now;
                     db.SaveChanges();
                 }
                 else
                 {
                     MobileOtp mobileOtp = new MobileOtp()
                     {
                         MobileNo         = mobileOtpDetails.MobileNo,
                         OTP              = mobileOtpDetails.OTP,
                         OTPSendCount     = 1,
                         IsActive         = true,
                         CreatedDateTime  = DateTime.Now,
                         ModifiedDateTime = DateTime.Now
                     };
                     db.MobileOtps.Add(mobileOtp);
                     db.SaveChanges();
                 }
                 transaction.Commit();
                 //Send sms on mobile
                 SendSMS(mobileOtpDetails.MobileNo, mobileOtpDetails.OTP);
                 return(true);
             }
             catch (Exception Ex)
             {
                 string msg = Ex.ToString();
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
Exemplo n.º 5
0
 public string AddCart(BikeInfoById bikeInfoById)
 {
     using (var db = new ObickeEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 var alreadyExists = db.AddToCarts.Where(a => a.SecretToken == bikeInfoById.SecretToken && a.BikeId == bikeInfoById.BikeId).FirstOrDefault();
                 if (alreadyExists != null)
                 {
                     return("Already added in cart");
                 }
                 var count = db.AddToCarts.Where(a => a.SecretToken == bikeInfoById.SecretToken).Count();
                 if (count < 2)
                 {
                     AddToCart addToCart = new AddToCart()
                     {
                         BikeId           = bikeInfoById.BikeId,
                         SecretToken      = bikeInfoById.SecretToken,
                         InitiatedThrough = "Mobile",
                         CreatedDateTime  = DateTime.Now,
                         ModifiedDateTime = DateTime.Now
                     };
                     db.AddToCarts.Add(addToCart);
                     db.SaveChanges();
                     transaction.Commit();
                     return("Success");
                 }
                 else
                 {
                     return("Sorry, you can't add more than 2 bikes");
                 }
             }
             catch (Exception Ex)
             {
                 string msg = Ex.ToString();
                 transaction.Rollback();
                 return(Ex.Message);
             }
         }
     }
 }
Exemplo n.º 6
0
 public bool UpdatePostPaymentDetails(PaymentModule transactionDetail)
 {
     using (var db = new ObickeEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 //if OrderId is already exists, update the other inputs
                 var existsModel = db.TransactionDetails.Where(a => a.OrderId == transactionDetail.OrderId).FirstOrDefault();
                 if (existsModel != null)
                 {
                     existsModel.BankName    = transactionDetail.BankName;
                     existsModel.BankTxnId   = transactionDetail.BankTxnId;
                     existsModel.Currency    = transactionDetail.Currency;
                     existsModel.GatewayName = transactionDetail.GatewayName;
                     existsModel.IsCompleted = transactionDetail.IsCompleted;
                     existsModel.PaymentCompletedDateTime = DateTime.Now;
                     existsModel.PaymentMode  = transactionDetail.PaymentMode;
                     existsModel.ResponseCode = transactionDetail.ResponseCode;
                     existsModel.ResponseMsg  = transactionDetail.ResponseMsg;
                     existsModel.TxnAmount    = transactionDetail.TxnAmount;
                     existsModel.TxnDate      = DateTime.Now;
                     existsModel.TxnId        = transactionDetail.TxnId;
                     existsModel.TxnStatus    = transactionDetail.TxnStatus;
                     db.SaveChanges();
                 }
                 transaction.Commit();
                 return(true);
             }
             catch (Exception Ex)
             {
                 string msg = Ex.ToString();
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
Exemplo n.º 7
0
        public string SaveUserDetails(UserDetails userDetails)
        {
            using (var db = new ObickeEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var IsAlreadyExists = db.UserDetails.Where(a => a.SecretToken == userDetails.SecretToken).FirstOrDefault();
                        if (IsAlreadyExists != null)
                        {
                            IsAlreadyExists.Fullname         = userDetails.FullName;
                            IsAlreadyExists.UserEmailId      = userDetails.UserEmailId;
                            IsAlreadyExists.MobileNo         = userDetails.MobileNo;
                            IsAlreadyExists.CurrentLocation  = userDetails.Address;
                            IsAlreadyExists.AddressType      = userDetails.AddressType;
                            IsAlreadyExists.LandMark         = userDetails.LandMark;
                            IsAlreadyExists.TimeFrom         = Convert.ToInt32(userDetails.TimeFrom);
                            IsAlreadyExists.TimeTo           = Convert.ToInt32(userDetails.TimeTo);
                            IsAlreadyExists.AMPM             = userDetails.AMPM;
                            IsAlreadyExists.City             = userDetails.City;
                            IsAlreadyExists.Pincode          = userDetails.Pincode;
                            IsAlreadyExists.ModifiedDateTime = DateTime.Now;
                            db.SaveChanges();
                        }
                        else
                        {
                            UserDetail userD = new UserDetail()
                            {
                                Fullname         = userDetails.FullName,
                                UserEmailId      = userDetails.UserEmailId,
                                MobileNo         = userDetails.MobileNo,
                                SecretToken      = userDetails.SecretToken,
                                CurrentLocation  = userDetails.Address,
                                AddressType      = userDetails.AddressType,
                                LandMark         = userDetails.LandMark,
                                IsVerified       = true,
                                IsActive         = true,
                                TimeFrom         = Convert.ToInt32(userDetails.TimeFrom),
                                TimeTo           = Convert.ToInt32(userDetails.TimeTo),
                                AMPM             = userDetails.AMPM,
                                City             = userDetails.City,
                                Pincode          = userDetails.Pincode,
                                CreatedDateTime  = DateTime.Now,
                                ModifiedDateTime = DateTime.Now
                            };
                            db.UserDetails.Add(userD);
                            db.SaveChanges();
                        }

                        var userCartDetailsCount = db.CartDetails.Where(a => a.SecretToken == userDetails.SecretToken).Count();
                        if (userCartDetailsCount != 0)
                        {
                            var alreadyExists = db.CartDetails.Where(a => a.SecretToken == userDetails.SecretToken).ToList();
                            db.CartDetails.RemoveRange(alreadyExists);
                            db.SaveChanges();
                        }
                        foreach (var bikeId in userDetails.BikecartlistIds)
                        {
                            var cartD = new CartDetail()
                            {
                                BikeId             = bikeId.BikeId,
                                SecretToken        = userDetails.SecretToken,
                                RequestGeneratedBy = "mobile",
                                CreatedDateTime    = DateTime.Now,
                                ModifiedDateTime   = DateTime.Now
                            };
                            db.CartDetails.Add(cartD);
                            db.SaveChanges();
                        }
                        transaction.Commit();
                        return("Success");
                    }
                    catch (Exception Ex)
                    {
                        string msg = Ex.ToString();
                        transaction.Rollback();
                        return(msg);
                    }
                }
            }
        }
Exemplo n.º 8
0
 public bool SavePrePaymentDetails(PaymentModule transactionDetail)
 {
     using (var db = new ObickeEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 //if OrderId is already exists, update the other inputs
                 var existsModel = db.TransactionDetails.Where(a => a.OrderId == transactionDetail.OrderId).FirstOrDefault();
                 if (existsModel != null)
                 {
                     existsModel.BankName    = transactionDetail.BankName;
                     existsModel.BankTxnId   = transactionDetail.BankTxnId;
                     existsModel.Currency    = transactionDetail.Currency;
                     existsModel.CustomerId  = transactionDetail.CustomerId;
                     existsModel.EmailId     = transactionDetail.EmailId;
                     existsModel.GatewayName = transactionDetail.GatewayName;
                     existsModel.IsCompleted = transactionDetail.IsCompleted;
                     existsModel.MobileNo    = transactionDetail.MobileNo;
                     existsModel.PaymentCompletedDateTime = DateTime.Now;
                     existsModel.PaymentInitiatedDateTime = DateTime.Now;
                     existsModel.PaymentMode  = transactionDetail.PaymentMode;
                     existsModel.ResponseCode = transactionDetail.ResponseCode;
                     existsModel.ResponseMsg  = transactionDetail.ResponseMsg;
                     existsModel.TxnAmount    = transactionDetail.TxnAmount;
                     existsModel.TxnDate      = DateTime.Now;
                     existsModel.TxnId        = transactionDetail.TxnId;
                     existsModel.TxnStatus    = transactionDetail.TxnStatus;
                     existsModel.UserName     = transactionDetail.UserName;
                     db.SaveChanges();
                 }
                 else
                 {
                     //Save new entry
                     var transactionsModel = new TransactionDetail()
                     {
                         BankName    = transactionDetail.BankName,
                         BankTxnId   = transactionDetail.BankTxnId,
                         Currency    = transactionDetail.Currency,
                         CustomerId  = transactionDetail.CustomerId,
                         EmailId     = transactionDetail.EmailId,
                         GatewayName = transactionDetail.GatewayName,
                         IsCompleted = transactionDetail.IsCompleted,
                         MobileNo    = transactionDetail.MobileNo,
                         OrderId     = transactionDetail.OrderId,
                         PaymentCompletedDateTime = DateTime.Now,
                         PaymentInitiatedDateTime = DateTime.Now,
                         PaymentMode  = transactionDetail.PaymentMode,
                         ResponseCode = transactionDetail.ResponseCode,
                         ResponseMsg  = transactionDetail.ResponseMsg,
                         TxnAmount    = transactionDetail.TxnAmount,
                         TxnDate      = DateTime.Now,
                         TxnId        = transactionDetail.TxnId,
                         TxnStatus    = transactionDetail.TxnStatus,
                         UserName     = transactionDetail.UserName
                     };
                     db.TransactionDetails.Add(transactionsModel);
                     db.SaveChanges();
                 }
                 transaction.Commit();
                 return(true);
             }
             catch (Exception Ex)
             {
                 string msg = Ex.ToString();
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }