public IHttpActionResult PuttblInsuranceClaim(int id, tblInsuranceClaim tblInsuranceClaim)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblInsuranceClaim.Cliamid)
            {
                return(BadRequest());
            }

            db.Entry(tblInsuranceClaim).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblInsuranceClaimExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public dynamic UpdatePassword(string email, string password)
        {
            List <tblFarmer> far = db.tblFarmers.ToList();
            List <tblBidder> bid = db.tblBidders.ToList();

            foreach (var item in far)
            {
                if (item.FarmerEmail == email)
                {
                    item.FarmerPassword = password;
                    byte[] encData_byte = new byte[item.FarmerPassword.Length];
                    encData_byte = System.Text.Encoding.UTF8.GetBytes(item.FarmerPassword);
                    string encodedpassword = Convert.ToBase64String(encData_byte);
                    item.FarmerPassword = encodedpassword;

                    db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Valid"));
                }
            }

            foreach (var item in bid)
            {
                if (item.BidderEmail == email)
                {
                    item.BidderPassword  = password;
                    db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Valid"));
                }
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound, "NotFound"));
        }
        public HttpResponseMessage WayTwo()
        {
            string imageName   = "";
            string Qty         = "";
            var    httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFile = httpRequest.Files["Image"];

            //Create custom filename
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);

            postedFile.SaveAs(filePath);

            //Save to DB
            using (dbProjectEntities1 db = new dbProjectEntities1())
            {
                tblCropRequest cpr = new tblCropRequest();

                cpr.SoilPhCertificate = imageName;
                cpr.CropType          = httpRequest["CropType"];
                cpr.CropName          = httpRequest["CropName"];
                cpr.FertilizerType    = httpRequest["FertilizerType"];
                Qty = (httpRequest["Quantity"]);
                //Quantity = 25
                cpr.Quantity     = Convert.ToInt32(Qty);
                cpr.Farmerid     = Convert.ToInt32(httpRequest["FarmerID"]);
                cpr.CropApproved = false;
                db.tblCropRequests.Add(cpr);
                db.SaveChanges();
            }
            return(Request.CreateResponse(HttpStatusCode.Created));
        }
 public void Listing([FromBody] tblCropRequest cropRequest)
 {
     cropRequest.SoilPhCertificate = cropRequest.SoilPhCertificate.Replace("/", "-");
     cropRequest.Farmerid          = 100;
     cropRequest.CropApproved      = false;
     db.tblCropRequests.Add(cropRequest);
     db.SaveChanges();
 }
        public IHttpActionResult PostInsuranceRegistration(InsuranceApp regfom)
        {
            tblInsurance tblInsurance = new tblInsurance();

            tblInsurance.Season          = regfom.Season;
            tblInsurance.Area            = regfom.Area;
            tblInsurance.Farmerid        = Convert.ToInt32(regfom.Farmerid);
            tblInsurance.CompanyName     = regfom.CompanyName;
            tblInsurance.SumInsured      = regfom.SumAssured;
            tblInsurance.Year            = regfom.Year;
            tblInsurance.DateOfInsurance = DateTime.Today;
            tblInsurance.Crop            = regfom.CropName;
            db.tblInsurances.Add(tblInsurance);
            db.SaveChanges();
            return(Ok("OK"));
        }
        public IHttpActionResult Post([FromUri] string mail, int id)
        {
            var currentmsg = db.tblContactUs.Where(c => c.Email.Equals(mail))
                             .FirstOrDefault <tblContactU>();

            if (currentmsg != null)
            {
                currentmsg.status          = "Replied";
                currentmsg.ApprovalAdminId = id;
                db.SaveChanges();
            }
            else
            {
                return(NotFound());
            }
            return(Ok());
        }
        public void Post([FromBody] tblContactU contactU)
        {
            try
            {
                tblContactU c = new tblContactU();
                c.ContactName     = contactU.ContactName;
                c.Email           = contactU.Email;
                c.RequestType     = contactU.RequestType;
                c.message         = contactU.message;
                c.status          = "Not Seen";
                c.ApprovalAdminId = null;

                db.tblContactUs.Add(c);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public IHttpActionResult WayTwo()
        {
            string imageName  = "";
            string imageName1 = "";

            string Qty         = "";
            var    httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFile  = httpRequest.Files["Image"];
            var postedFile1 = httpRequest.Files["Image1"];

            //Create custom filename
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);

            postedFile.SaveAs(filePath);

            imageName1 = new String(Path.GetFileNameWithoutExtension(postedFile1.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName1 = imageName1 + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile1.FileName);
            var filePath1 = HttpContext.Current.Server.MapPath("~/Image/" + imageName1);

            postedFile1.SaveAs(filePath1);


            tblBidder br = new tblBidder();

            //Save to DB
            using (dbProjectEntities1 db = new dbProjectEntities1())
            {
                List <tblBidder> bidders = db.tblBidders.ToList();
                List <tblBank>   banks   = db.tblBanks.ToList();

                foreach (tblBidder tblBidder1 in bidders)
                {
                    if (tblBidder1.BidderEmail == httpRequest["BidderEmail"])
                    {
                        return(Ok("Email"));
                    }
                }

                foreach (tblBank tblBank1 in banks)
                {
                    if (tblBank1.AccountNo == httpRequest["AccountNo"])
                    {
                        return(Ok("Account"));
                    }
                }

                try
                {
                    #region saving details into db
                    br.BidderAadhar       = imageName;
                    br.BidderTradeLicense = imageName1;

                    br.BidderName      = httpRequest["BidderName"];
                    br.BidderEmail     = httpRequest["BidderEmail"];
                    br.BidderContactNo = httpRequest["BidderContactNo"];
                    br.BidderAddress   = httpRequest["BidderAddress"];
                    br.BidderCity      = httpRequest["BidderCity"];
                    br.BidderState     = httpRequest["BidderState"];
                    br.BidderPincocde  = httpRequest["BidderPincocde"];
                    br.BidderPassword  = httpRequest["BidderPassword"];
                    byte[] encData_byte = new byte[br.BidderPassword.Length];
                    encData_byte = System.Text.Encoding.UTF8.GetBytes(br.BidderPassword);
                    string encodedpassword = Convert.ToBase64String(encData_byte);
                    br.BidderPassword = encodedpassword;

                    br.BidderApproved = false;
                    db.tblBidders.Add(br);
                    db.SaveChanges();

                    List <tblBidder> res = db.tblBidders.ToList();
                    foreach (tblBidder item in res)
                    {
                        if (item.BidderEmail == br.BidderEmail)
                        {
                            bid = item.Bidderid;
                            break;
                        }
                    }

                    tblBank tb1 = new tblBank();
                    tb1.Farmerid  = null;
                    tb1.AccountNo = httpRequest["AccountNo"];
                    tb1.IFSC_Code = httpRequest["IFSC_Code"];
                    tb1.Bidderid  = bid;

                    db.tblBanks.Add(tb1);
                    db.SaveChanges();
                    #endregion
                }
                catch
                {
                    return(Ok("Error"));
                }
            }
            return(Ok("OK"));
        }
 public void post([FromBody] tblInsuranceClaim insuranceCliam)
 {
     insuranceCliam.ApprovalStatus = "Not Approved";
     db.tblInsuranceClaims.Add(insuranceCliam);
     db.SaveChanges();
 }
Ejemplo n.º 10
0
        public IHttpActionResult WayTwo()
        {
            string imageName  = "";
            string imageName1 = "";

            string Qty         = "";
            var    httpRequest = HttpContext.Current.Request;
            //Upload Image
            var postedFile  = httpRequest.Files["Image"];
            var postedFile1 = httpRequest.Files["Image1"];

            //Create custom filename
            imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);

            postedFile.SaveAs(filePath);

            imageName1 = new String(Path.GetFileNameWithoutExtension(postedFile1.FileName).Take(10).ToArray()).Replace(" ", "-");
            imageName1 = imageName1 + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile1.FileName);
            var filePath1 = HttpContext.Current.Server.MapPath("~/Image/" + imageName1);

            //var filePath1 = HttpContext.Current.Server.MapPath("D:/Project_Angular/AgriFarmProj/src/assets/uploadeddocs/" + imageName1);
            postedFile1.SaveAs(filePath1);


            tblFarmer fmr = new tblFarmer();

            //Save to DB
            using (dbProjectEntities1 db = new dbProjectEntities1())
            {
                #region saving data into db
                List <tblFarmer> farmers = db.tblFarmers.ToList();
                List <tblBank>   banks   = db.tblBanks.ToList();

                foreach (tblFarmer tblFarmer1 in farmers)
                {
                    if (tblFarmer1.FarmerEmail == httpRequest["FarmerEmail"])
                    {
                        return(Ok("Email"));
                    }
                }

                foreach (tblBank tblBank1 in banks)
                {
                    if (tblBank1.AccountNo == httpRequest["AccountNo"])
                    {
                        return(Ok("Account"));
                    }
                }
                try {
                    fmr.FarmerAadhar      = imageName;
                    fmr.FarmerCertificate = imageName1;

                    fmr.FarmerName      = httpRequest["FarmerName"];
                    fmr.FarmerContactNo = httpRequest["FarmerContactNo"];
                    fmr.FarmerAddress   = httpRequest["FarmerAddress"];
                    fmr.FarmerCity      = httpRequest["FarmerCity"];
                    fmr.FarmerState     = httpRequest["FarmerState"];
                    fmr.FarmerPincocde  = httpRequest["FarmerPincocde"];
                    fmr.FarmerEmail     = httpRequest["FarmerEmail"];
                    fmr.FarmerPassword  = httpRequest["FarmerPassword"];
                    fmr.FarmerApproved  = false;
                    byte[] encData_byte = new byte[fmr.FarmerPassword.Length];
                    encData_byte = System.Text.Encoding.UTF8.GetBytes(fmr.FarmerPassword);
                    string encodedpassword = Convert.ToBase64String(encData_byte);
                    fmr.FarmerPassword = encodedpassword;
                    db.tblFarmers.Add(fmr);
                    db.SaveChanges();


                    // db.SaveChanges();

                    /*
                     *          }*/
                    List <tblFarmer> res = db.tblFarmers.ToList();

                    foreach (tblFarmer item in res)
                    {
                        if (item.FarmerEmail == fmr.FarmerEmail)
                        {
                            fid = item.Farmerid;
                            break;
                        }
                    }

                    tblBank tb1 = new tblBank();

                    using (dbProjectEntities1 db1 = new dbProjectEntities1())
                    {
                        tb1.Farmerid  = fid;
                        tb1.AccountNo = httpRequest["AccountNo"];
                        tb1.IFSC_Code = httpRequest["IFSC_Code"];
                        tb1.Bidderid  = null;

                        db1.tblBanks.Add(tb1);
                        db1.SaveChanges();

                        // db.SaveChanges();
                    }

                    tblFarmLand tb2 = new tblFarmLand();

                    using (dbProjectEntities1 db1 = new dbProjectEntities1())
                    {
                        tb2.Farmerid = fid;

                        tb2.FarmerLandArea    = httpRequest["FarmerLandArea"];
                        tb2.FarmerLandAddress = httpRequest["FarmerLandAddress"];
                        tb2.FarmerLandPincode = httpRequest["FarmerLandPincode"];
                        db1.tblFarmLands.Add(tb2);
                        db1.SaveChanges();
                    }
                    #endregion
                }
                catch (Exception)
                {
                    return(Ok("Error"));
                }
            }
            return(Ok("OK"));
        }