Example #1
0
        public bool IsCategoryNameExist(CategoryVM cat)
        {
            ExcellentMarketResearchEntities db = new ExcellentMarketResearchEntities();

            bool flag = false;

            //same name of child and parent cat,to check that find out the catid of same catname
            var Catid = db.CategoryMasters.Where(x => x.CategoryName == cat.CategoryName).Select(x => x.CategoryId).FirstOrDefault();

            //Same name of Category of same parentcategory, to check that find out the parent of same catname
            var Parentcatid = db.CategoryMasters.Where(x => x.CategoryName == cat.CategoryName).Select(x => x.ParentCategoryId).FirstOrDefault();

            if (Catid != 0 || Parentcatid != null)
            {
                //check the condition if true duplicate catname error ...
                if (Catid == cat.ParentCategoryId || Parentcatid == cat.ParentCategoryId)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }

            return(flag);
        }
Example #2
0
        public static BuyingInfo GetBuyerByGuId(string guid)
        {
            ExcellentMarketResearchEntities db = new ExcellentMarketResearchEntities();

            //var buyer = db.BuyingInfoes.Where(x => x.GuId == guid).Select new BuyingInfo(


            //).FirstOrDefault();

            var buyer = (from l in db.BuyingInfoes
                         where l.GuId == guid
                         select l).FirstOrDefault();

            return(buyer);
        }
Example #3
0
        public static bool PayPalProcess(PaymentLibrary.PayPal.PayPalResponse paypalResponse)
        {
            ExcellentMarketResearchEntities db = new ExcellentMarketResearchEntities();

            if (paypalResponse != null && (!string.IsNullOrEmpty(paypalResponse.PAYERID) || !string.IsNullOrEmpty(paypalResponse.guid)))
            {
                BuyingInfo b = new BuyingInfo();

                if (string.IsNullOrEmpty(paypalResponse.PAYERID))
                {
                    log4net.LogManager.GetLogger("Error").Error("PayerID not found OR Response is null OR guid is not found.\nData - " + Newtonsoft.Json.JsonConvert.SerializeObject(paypalResponse));
                }

                //TODO: Get buyer from table using guid

                var buyer = GetBuyerByGuId(paypalResponse.guid);

                //bool IsBuyerExist= buyer.Count(x=>x.GuId==paypalResponse.guid)>0?true:false;
                bool IsBuyerExist = buyer != null ? true : false;

                //TODO: Check buyer if exist or not
                if (IsBuyerExist == null)
                {
                    // log4net.logmanager.getlogger("error").error("buyer not found.\ndata - " + newtonsoft.json.jsonconvert.serializeobject(paypalresponse));
                    return(false);
                }


                ValidResponse vResponse = PaymentLibrary.PayPal.PayPal.IsPaymentValid(paypalResponse,
                                                                                      PayPalConfig.GetConfiguration(HttpContext.Current.Server.MapPath("/paypalconfig/paypal.config"), false), false);

                if (vResponse.IsValid)
                {
                    //TODO: update status of payment transaction to success

                    var updatestatus = db.BuyingInfoes.Where(x => x.GuId == paypalResponse.guid).FirstOrDefault();
                    b.PaymentTransaction            = true;
                    updatestatus.PaymentTransaction = b.PaymentTransaction;
                    db.Entry(updatestatus).State    = EntityState.Modified;
                    db.SaveChanges();
                    return(true);
                }
                Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
                Stream     s = new MemoryStream();
                TextWriter t = new StreamWriter(s);

                serializer.Serialize(t, paypalResponse);
                TextReader r = new StreamReader(s);

                //TODO: Save error to db

                //_saveStatus(, 'f', vResponse.Reason + "|ErrorCode - " + vResponse.ErrorCode + "|PaypalResponse - " + r.ReadToEnd());

                var saveError = db.BuyingInfoes.Where(x => x.GuId == paypalResponse.guid).FirstOrDefault();
                b.PaymentTransaction         = false;
                saveError.PaymentTransaction = b.PaymentTransaction;
                saveError.ErrorReason        = vResponse.Reason;
                saveError.ErrorCode          = vResponse.ErrorCode;
                db.Entry(saveError).State    = EntityState.Modified;
                db.SaveChanges();

                return(false);
            }
            return(false);
        }
Example #4
0
 public CategoryRepository()
 {
     db = new ExcellentMarketResearchEntities();
 }