コード例 #1
0
        public HttpResponseMessage TagReplacementRequest(HttpRequestMessage request, clsTagReplacement ctr)
        {
            if (ctr == null)
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest, ctr));
            }

            try
            {
                TagReplacementReq trr = new TagReplacementReq();
                trr.ReqDate = DateTime.Now;
                trr.OldSrNo = ctr.oldTagSrNo;
                //trr.CustID = ctr.custMobNo;

                trr.VehicleNo    = ctr.vehicleNo;
                trr.VehicleClass = ctr.vehicleClass;
                Random rnd   = new Random();
                int    value = rnd.Next(100000, 999999);
                trr.OTP           = value;
                trr.Reason        = ctr.reason;
                trr.SalesPersonID = ctr.SalesPersonID;
                trr.DistID        = ctr.distID;
                db.TagReplacementReqs.Add(trr);
                db.SaveChanges();
                trr.SrNo = trr.SrNo;
                return(request.CreateResponse(HttpStatusCode.OK, trr));
            }
            catch (Exception ex)
            {
                return(request.CreateResponse(HttpStatusCode.InternalServerError, ctr));
            }

            return(request.CreateResponse(HttpStatusCode.OK, ctr));
        }
コード例 #2
0
        public HttpResponseMessage SalesPersonTagReplacementRequest(HttpRequestMessage request, clsTagReplacement ctr)
        {
            if (ctr == null)
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest, ctr));
            }

            try
            {
                TagReplacementReq trr = new TagReplacementReq();

                trr.ReqDate      = DateTime.Now;
                trr.OldSrNo      = ctr.oldTagSrNo;
                trr.CustMobNo    = ctr.custMobNo;
                trr.VehicleNo    = ctr.vehicleNo;
                trr.VehicleClass = ctr.vehicleClass;
                Random rnd   = new Random();
                int    value = rnd.Next(100000, 999999);
                trr.OTP           = value;
                trr.Reason        = ctr.reason;
                trr.SalesPersonID = ctr.SalesPersonID;
                trr.DistID        = ctr.distID;
                db.TagReplacementReqs.Add(trr);
                db.SaveChanges();

                ecom_RFID ecr = db.ecom_RFID.Where(x => x.Serial_Number == ctr.oldTagSrNo).FirstOrDefault();
                ecr.ecom_RFIDStatus = "r";
                db.SaveChanges();
                ecom_RFID ecrn = db.ecom_RFID.Where(x => x.Serial_Number == ctr.newTagSrNo).FirstOrDefault();
                ecrn.ecom_CustomerMobNo     = ctr.custMobNo;
                ecrn.ecom_CustomerVehicleNo = ctr.vehicleNo;
                ecrn.ecom_RFIDStatus        = "a";
                db.SaveChanges();
                decimal amt = -100;
                DistributorCreditAccount dcr = db.DistributorCreditAccounts.FirstOrDefault();
                dcr.Amount      = Convert.ToDecimal("-100");
                dcr.DepositDate = DateTime.Now;
                string msg        = dcr.DepositedVia;
                string tagSrNoNew = ctr.newTagSrNo;
                int    len        = tagSrNoNew.Length;
                dcr.DepositedVia = "For tag replacement with serial no " + msg.Substring(len - 4);
                db.DistributorCreditAccounts.Add(dcr);

                db.SaveChanges();
                //update ecomRFID table row for old serial no. with status R
                //update ecomRFID table row for new serial no. with status A with customer's mob and vehicle no.
                //insert into DistributorCreditAccount a debit of -100 for tag replacement with srno.(last four character)
                trr.SrNo = trr.SrNo;
                return(request.CreateResponse(HttpStatusCode.OK, trr));
            }
            catch (Exception ex)
            {
                return(request.CreateResponse(HttpStatusCode.InternalServerError, ctr));
            }

            return(request.CreateResponse(HttpStatusCode.OK, ctr));
        }