public int PostExcelData(string BuyerName, string MobileNo)
        {
            Buyer_Detail bd           = new Buyer_Detail();
            var          alreadyBuyer = db.BuyerDetails.Where(x => x.MobileNo == MobileNo).FirstOrDefault();

            if (alreadyBuyer == null)
            {
                bd.BuyerName = BuyerName;
                bd.MobileNo  = MobileNo;
                db.BuyerDetails.Add(bd);
            }

            db.SaveChanges();
            return(1);
        }
        public ActionResult AssignLeadToManager(Buyer_Detail bd)
        {
            try
            {
                Buyer_Detail  BuyerDetail   = new Buyer_Detail();
                BuyerRelation BuyerRelation = new BuyerRelation();

                var currentBuyerDetail = db.BuyerDetails.FirstOrDefault(b => b.BuyerId == bd.BuyerId);
                if (currentBuyerDetail == null)
                {
                    return(HttpNotFound());
                }
                currentBuyerDetail.ManagerAssigned = bd.ManagerAssigned;

                var currentBuyerRelation = db.BuyerRelation.FirstOrDefault(b => b.BuyerId == bd.BuyerId);
                if (currentBuyerRelation == null)
                {
                    BuyerRelation.BuyerId   = bd.BuyerId;
                    BuyerRelation.ManagerId = bd.ManagerAssigned;
                    BuyerRelation.UpdatedOn = DateTime.Now;
                    db.BuyerRelation.Add(BuyerRelation);
                }
                else
                {
                    currentBuyerRelation.ManagerId          = bd.ManagerAssigned;
                    currentBuyerRelation.UpdatedOn          = DateTime.Now;
                    currentBuyerRelation.AssistantManagerId = null;
                    currentBuyerRelation.MemberId           = null;
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(View("Error"));
            }
        }