public ActionResult MarkAsPaid(int?id) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Unauthorized_Access", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompletedBids completedBids = db.CompletedBids.Find(id); if (completedBids == null) { return(HttpNotFound()); } if (completedBids.ContractorPaid == true) { return(RedirectToAction("Already_Paid", "CompletedBids")); } completedBids.ContractorPaid = true; db.SaveChanges(); return(View("PayContractor", completedBids)); }
public ActionResult Create([Bind(Include = "ID,ConUsername,HomeUsername,ConFirstName,HomeFirstname,ConLastName,HomeLastName,ConAddress,HomeAddress,ConCity,HomeCity,ConState,HomeState,ConZip,HomeZip,ConEmail,HomeEmail,PostedDate,Bid,CompletionDeadline,Description,Completed,Invoice,ConstactorPaid,ConstactorDue,Expired,Service_Number")] CompletedBids completedBids, HttpPostedFileBase upload) { if (ModelState.IsValid) { if (upload != null && upload.ContentLength > 0) { var picture = new File { FileName = System.IO.Path.GetFileName(upload.FileName), FileType = FileType.Picture, ContentType = upload.ContentType }; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { picture.Content = reader.ReadBytes(upload.ContentLength); } completedBids.Files = new List <File> { picture }; } db.CompletedBids.Add(completedBids); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(completedBids)); }
public ActionResult getPayment(int?ID) { CompletedBids bid = new CompletedBids(); bid = db.CompletedBids.Find(ID); return(View(bid)); }
public ActionResult DeleteConfirmed(int id) { CompletedBids completedBids = db.CompletedBids.Find(id); db.CompletedBids.Remove(completedBids); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,ConUsername,HomeUsername,ConFirstName,HomeFirstname,ConLastName,HomeLastName,ConAddress,HomeAddress,ConCity,HomeCity,ConState,HomeState,ConZip,HomeZip,ConEmail,HomeEmail,PostedDate,Bid,CompletionDeadline,Description,Completed,Invoice,ContractorPaid,ContractorDue,Expired,Service_Number,Review,Rating")] CompletedBids completedBids) { if (completedBids.Review == null) { if (ModelState.IsValid) { db.Entry(completedBids).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(completedBids)); } if (ModelState.IsValid) { Reviews review = new Reviews(); review.ConUsername = completedBids.ConUsername; review.HomeUsername = completedBids.HomeUsername; review.ConFirstName = completedBids.ConFirstName; review.HomeFirstname = completedBids.HomeFirstname; review.ConLastName = completedBids.ConLastName; review.HomeLastName = completedBids.HomeLastName; review.ConAddress = completedBids.ConAddress; review.HomeAddress = completedBids.HomeAddress; review.ConCity = completedBids.ConCity; review.HomeCity = completedBids.HomeCity; review.ConState = completedBids.ConState; review.HomeState = completedBids.HomeState; review.ConZip = completedBids.ConZip; review.HomeZip = completedBids.HomeZip; review.ConEmail = completedBids.ConEmail; review.HomeEmail = completedBids.HomeEmail; review.PostedDate = completedBids.PostedDate; review.Bid = completedBids.Bid; review.CompletionDeadline = completedBids.CompletionDeadline; review.Description = completedBids.Description; review.Completed = completedBids.Completed; review.Invoice = completedBids.Invoice; review.ContractorDue = completedBids.ContractorDue; review.ContractorPaid = completedBids.ContractorPaid; review.Service_Number = completedBids.Service_Number; review.Expired = completedBids.Expired; review.Review = completedBids.Review; review.Rating = completedBids.Rating; db.Reviews.Add(review); db.Entry(completedBids).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(completedBids)); }
public ActionResult Add_Review(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompletedBids completedBids = db.CompletedBids.Find(id); if (completedBids == null) { return(HttpNotFound()); } return(View(completedBids)); }
public ActionResult Paid(int?id) { string identity = System.Web.HttpContext.Current.User.Identity.GetUserId(); CompletedBids completedBids = db.CompletedBids.Find(id); if (identity == null) { return(RedirectToAction("Unauthorized_Access", "Home")); } var completedList = db.CompletedBids.ToList(); string HomeOwnerEmail = ""; string payeeEmail = ""; var person = db.Homeowners.Where(x => x.UserId == identity).SingleOrDefault(); foreach (var user in db.Users) { if (user.Id == identity) { payeeEmail = user.Email; } } foreach (var i in completedList) { if (id == i.ID) { HomeOwnerEmail = i.HomeEmail; } } if (this.User.IsInRole("Admin") || HomeOwnerEmail == payeeEmail) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (completedBids == null) { return(HttpNotFound()); } } return(View(completedBids)); }
// GET: CompletedBids/Details/5 public ActionResult Details(int?id) { if (!this.User.IsInRole("Admin")) { return(RedirectToAction("Unauthorized_Access", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompletedBids completedBids = db.CompletedBids.Find(id); CompletedBids Pics = db.CompletedBids.Include(i => i.ServiceRequestPaths).SingleOrDefault(i => i.ID == id); if (completedBids == null) { return(HttpNotFound()); } return(View(completedBids)); }
public ActionResult SuccessView(int?id) { string identity = System.Web.HttpContext.Current.User.Identity.GetUserId(); CompletedBids completedBids = db.CompletedBids.Find(id); if (identity == null) { return(RedirectToAction("Unauthorized_Access", "Home")); } var completedList = db.CompletedBids.ToList(); string HomeOwnerEmail = ""; string payeeEmail = ""; var person = db.Homeowners.Where(x => x.UserId == identity).SingleOrDefault(); foreach (var user in db.Users) { if (user.Id == identity) { payeeEmail = user.Email; } } foreach (var i in completedList) { if (id == i.ID) { HomeOwnerEmail = i.HomeEmail; } } if (this.User.IsInRole("Admin") || HomeOwnerEmail == payeeEmail) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (completedBids == null) { return(HttpNotFound()); } if (completedBids.ContractorPaid == true) { return(RedirectToAction("Paid", new { id = completedBids.ID })); } completedBids.ContractorPaid = true; db.SaveChanges(); var myMessage = new SendGrid.SendGridMessage(); string name = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt"); string pass = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt"); myMessage.AddTo(completedBids.HomeEmail); myMessage.From = new MailAddress("*****@*****.**", "Admin"); myMessage.Subject = "Job Complete!!"; string url = "http://localhost:14703/CompletedBids/Add_Review/" + completedBids.ID; String message = "Hello " + completedBids.HomeFirstname + "," + "<br>" + "<br>" + "Thank you for using Work Warriors! To review " + completedBids.ConUsername + "'s service, please click on link below: <br><a href =" + url + "> Click Here </a>"; myMessage.Html = message; var credentials = new NetworkCredential(name, pass); var transportWeb = new SendGrid.Web(credentials); transportWeb.DeliverAsync(myMessage); ConPaidMail(completedBids.ConEmail, completedBids.ConUsername, completedBids.ContractorDue); } return(View(completedBids)); }
public ActionResult Payment(int?id) { string identity = System.Web.HttpContext.Current.User.Identity.GetUserId(); if (identity == null) { return(RedirectToAction("Unauthorized_Access", "Home")); } var completedList = db.CompletedBids.ToList(); string HomeOwnerEmail = ""; string payeeEmail = ""; var person = db.Homeowners.Where(x => x.UserId == identity).SingleOrDefault(); foreach (var user in db.Users) { if (user.Id == identity) { payeeEmail = user.Email; } } foreach (var i in completedList) { if (id == i.ID) { HomeOwnerEmail = i.HomeEmail; } } if (this.User.IsInRole("Admin") || HomeOwnerEmail == payeeEmail) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompletedBids completedBids = db.CompletedBids.Find(id); if (completedBids == null) { return(HttpNotFound()); } ReceiverList receiverList = new ReceiverList(); receiverList.receiver = new List <Receiver>(); Receiver receiver = new Receiver(completedBids.Bid); //var query = from v in db.Ventures where v.Id == bid.ventureID select v.investorID; //string receiverID = query.ToList().ElementAt(0); //ApplicationUser recvUser = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(receiverID.ToString()); receiver.email = "*****@*****.**"; receiver.primary = true; receiverList.receiver.Add(receiver); Receiver receiver2 = new Receiver(completedBids.ContractorDue); //var query = from v in db.Ventures where v.Id == bid.ventureID select v.investorID; //string receiverID = query.ToList().ElementAt(0); //ApplicationUser recvUser = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(receiverID.ToString()); receiver2.email = completedBids.ConEmail; receiver2.primary = false; receiverList.receiver.Add(receiver2); RequestEnvelope requestEnvelope = new RequestEnvelope("en_US"); string actionType = "PAY"; string successUrl = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/CompletedBids/SuccessView/{0}"; string failureUrl = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/CompletedBids/FailureView/{0}"; successUrl = String.Format(successUrl, id); failureUrl = String.Format(failureUrl, id); string returnUrl = successUrl; string cancelUrl = failureUrl; string currencyCode = "USD"; PayRequest payRequest = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl); payRequest.ipnNotificationUrl = "http://cf719b5f.ngrok.io"; string memo = completedBids.Description + " Invoice = " + completedBids.Invoice; payRequest.memo = memo; Dictionary <string, string> sdkConfig = new Dictionary <string, string>(); sdkConfig.Add("mode", "sandbox"); sdkConfig.Add("account1.apiUsername", "mattjheller-facilitator_api1.yahoo.com"); //PayPal.Account.APIUserName sdkConfig.Add("account1.apiPassword", "DG6GB55TRBWLESWG"); //PayPal.Account.APIPassword sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31AafAKKwBsAp2EBV9PExGkablGWhj"); //.APISignature sdkConfig.Add("account1.applicationId", "APP-80W284485P519543T"); //.ApplicatonId AdaptivePaymentsService adaptivePaymentsService = new AdaptivePaymentsService(sdkConfig); PayResponse payResponse = adaptivePaymentsService.Pay(payRequest); ViewData["paykey"] = payResponse.payKey; //string payKey = payResponse.payKey; //////// //string paymentExecStatus = payResponse.paymentExecStatus; //string payURL = String.Format("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey={0}", payKey); return(View(completedBids)); } else { return(RedirectToAction("Unauthorized_Access", "Home")); } }
public ActionResult confirmCompletion(int id) { //if (this.User.IsInRole"conr"){ //} //} string ConEmail = ""; string ConUserName = ""; string ConFirstName = ""; string ConLastName = ""; string ConAddress = ""; string ConCity = ""; string ConState = ""; string ConZip = ""; int Invoice = 1; var myMessage = new SendGrid.SendGridMessage(); string name = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt"); string pass = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt"); var contractors = db.Contractors.ToList(); var homeowners = db.Homeowners.ToList(); var servicerequests = db.ServiceRequests.ToList(); var acceptList = db.ContractorAcceptedBids.ToList(); var confirmedList = db.HomeownerComfirmedBids.ToList(); var completedList = db.CompletedBids.ToList(); string identity = System.Web.HttpContext.Current.User.Identity.GetUserId(); var person = db.Contractors.Where(x => x.UserId == identity).SingleOrDefault(); foreach (var user in db.Users) { if (user.Id == identity) { ConEmail = user.Email; //username1 = user.UserName; foreach (var con in contractors) { if (con.email == ConEmail) { ConUserName = con.Username; ConFirstName = con.FirstName; ConLastName = con.LastName; ConAddress = con.Address; ConCity = con.City; ConState = con.State; ConZip = con.Zip; } } } } foreach (var i in confirmedList) { if (id == i.ID) { CompletedBids bid = new CompletedBids(); bid.ServiceRequestPaths = new List <ServiceRequestPath>(); bid.AfterPaths = new List <AfterPath>(); bid.CompletedPaths = new List <CompletedPath>(); bid.ConUsername = i.ConUsername; bid.HomeUsername = i.HomeUsername; bid.ConFirstName = i.ConFirstName; bid.HomeFirstname = i.HomeFirstname; bid.ConLastName = i.ConLastName; bid.HomeLastName = i.HomeLastName; bid.ConAddress = i.ConAddress; bid.HomeAddress = i.HomeAddress; bid.ConCity = i.ConCity; bid.HomeCity = i.HomeCity; bid.ConState = i.ConState; bid.HomeState = i.HomeState; bid.ConZip = i.ConZip; bid.HomeZip = i.HomeZip; bid.ConEmail = i.ConEmail; bid.HomeEmail = i.HomeEmail; bid.PostedDate = i.PostedDate; bid.CompletionDeadline = i.CompletionDeadline; bid.Description = i.Description; bid.Bid = i.Bid; bid.Files = i.Files; bid.Service_Number = i.Service_Number; foreach (var x in completedList) { if (x.Service_Number == bid.Service_Number) { return(RedirectToAction("Already_Confirmed_Completion", "CompletedBids")); } } foreach (var x in i.ServiceRequestPaths) { bid.ServiceRequestPaths.Add(new ServiceRequestPath() { FileName = x.FileName }); } foreach (var x in i.AfterPaths) { bid.CompletedPaths.Add(new CompletedPath() { FileName = x.FileName }); } //bid.AfterPaths = i.AfterPaths; //foreach (var x in i.AfterPaths) //{ // bid.AfterPaths.Add(new AfterPath() { FileName = x.FileName }); // bid. = homeownerComfirmedBids.ID; //} //bid.Service_Number = i.Service_Number; bid.ContractorDue = i.Bid * .9m; bid.ContractorPaid = false; //foreach (var x in completedList) //{ // if (x.Service_Number == bid.Service_Number) // { // return RedirectToAction("Already_Confirmed_Completion", "CompletedBids"); // } //} bid.Completed = true; db.CompletedBids.Add(bid); i.Completed = true; db.SaveChanges(); Invoice = bid.ID; bid.Invoice = Invoice; myMessage.AddTo(i.HomeEmail); myMessage.From = new MailAddress("*****@*****.**", "Admin"); myMessage.Subject = "Job Complete!!"; string url = "http://localhost:14703/CompletedBids/Payment/" + Invoice; //string message = "Job Location: <br>" + i.Address + "<br>" + i.City + "<br>" + i.State + "<br>" + i.Zip + "<br>" + "<br>" + "Job Description: <br>" + i.Description + "<br>" + "<br>" + "Bid price: <br>$" + i.Bid + "<br>" + "<br>" + "Must be completed by: <br>" + i.CompletionDeadline + "<br>" + "<br>" + "Date Posted: <br>" + i.PostedDate + "<br>" + "<br>" + "To accept job, click on link below: <br><a href =" + url + "> Click Here </a>"; String message = "Hello " + i.HomeFirstname + "," + "<br>" + "<br>" + "Contractor " + ConUserName + " has completed your following service request:" + "<br>" + "<br>" + i.Description + "<br>" + "<br>" + "To complete payment, please click on link below: <br><a href =" + url + "> Click Here </a>"; myMessage.Html = message; var credentials = new NetworkCredential(name, pass); var transportWeb = new SendGrid.Web(credentials); transportWeb.DeliverAsync(myMessage); conList.Add(ConEmail + i.ID); } //i.posted = true; db.SaveChanges(); } return(RedirectToAction("About", "Home")); }