public HttpResponseMessage DBCurrency(DBoyCurrency obj, int PeopleID) //Order change delivery boy
 {
     try
     {
         var DBoyorders = context.DboyCu(obj, PeopleID);
         if (DBoyorders == null)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error Occured"));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, DBoyorders));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
        public dynamic CheckdeatilStock(CheckCurrency objlist, int PeopleID) //Order change delivery boy
        {
            try
            {
                var deliveryBoy = context.Peoples.Where(x => x.PeopleID == PeopleID && x.Deleted == false).FirstOrDefault();

                if (objlist != null)
                {
                    objlist.UpdatedDate = indianTime;
                    objlist.CreatedDate = indianTime;
                    //objlist.DboyName = deliveryBoy.DisplayName;
                    objlist.status = "Delivered Boy Check Inserted InCST";
                    context.CheckCurrencyDB.Add(objlist);
                    int id = context.SaveChanges();
                }
                if (deliveryBoy != null)
                {
                    DBoyCurrency db = context.DBoyCurrencyDB.Where(x => x.DBoyCId == objlist.DBoyCId).FirstOrDefault();

                    if (db != null)
                    {
                        db.checkrec = true;
                        context.DBoyCurrencyDB.Attach(db);
                        context.Entry(db).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(objlist);
        }
        public dynamic DBCurrencyStockhistorydue(CurrencyHistory objlist, int PeopleID) //Order change delivery boy
        {
            try
            {
                var deliveryBoy = context.Peoples.Where(x => x.PeopleID == PeopleID && x.Deleted == false).FirstOrDefault();
                if (objlist != null)
                {
                    var existDatas = context.CurrencyHistoryDB.Where(x => x.Deleted == false).FirstOrDefault();

                    if (existDatas == null)
                    {
                        objlist.UpdatedDate = indianTime;
                        objlist.CreatedDate = indianTime;
                        objlist.DboyName    = deliveryBoy.DisplayName;
                        objlist.status      = "Delivered Boy Currency Inserted InCST";
                        context.CurrencyHistoryDB.Add(objlist);
                        int id = context.SaveChanges();
                    }
                    else
                    {
                        var existData = context.CurrencyHistoryDB.Where(x => x.CurrencyHistoryid == existDatas.CurrencyHistoryid && x.Deleted == false).FirstOrDefault();

                        //CurrencyStock CST = new CurrencyStock();
                        existData.OneRupee      += objlist.OneRupee;
                        existData.onerscount    += objlist.onerscount;
                        existData.TwoRupee      += objlist.TwoRupee;
                        existData.tworscount    += objlist.tworscount;
                        existData.FiveRupee     += objlist.FiveRupee;
                        existData.fiverscount   += objlist.fiverscount;
                        existData.TenRupee      += objlist.TenRupee;
                        existData.tenrscount    += objlist.tenrscount;
                        existData.TwentyRupee   += objlist.TwentyRupee;
                        existData.Twentyrscount += objlist.Twentyrscount;
                        existData.fiftyRupee    += objlist.fiftyRupee;
                        existData.fiftyrscount  += objlist.fiftyrscount;
                        existData.HunRupee      += objlist.HunRupee;
                        existData.hunrscount    += objlist.hunrscount;
                        existData.fiveHRupee    += objlist.fiveHRupee;
                        existData.fivehrscount  += objlist.fivehrscount;
                        existData.twoTHRupee    += objlist.twoTHRupee;
                        existData.twoTHrscount  += objlist.twoTHrscount;
                        existData.TotalAmount   += objlist.TotalAmount;
                        existData.TotalAmount   += objlist.Dueamount;
                        //existData.Dueamount += objlist.Dueamount;
                        existData.UpdatedDate = indianTime;
                        context.CurrencyHistoryDB.Attach(existData);
                        context.Entry(existData).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                    if (deliveryBoy != null)
                    {
                        DBoyCurrency db = context.DBoyCurrencyDB.Where(x => x.DBoyCId == objlist.DBoyCId).FirstOrDefault();

                        db.Dueamountstatus = " Settled ";

                        context.DBoyCurrencyDB.Attach(db);
                        context.Entry(db).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(true);
        }