public RedirectResult Post(Donate donate) { order = new Order(); if (ModelState.IsValid && donate != null) { order.Amount = donate.amountOfDonation; order.Descriptioin = donate.Comment; order.Number = Guid.NewGuid().ToString(); order.Id = Guid.NewGuid().ToString(); string resultOrderResponse = helper.RegisterOrder(order).Result; dynamic parsejsonString = JObject.Parse(resultOrderResponse); string formUrl = parsejsonString.formUrl; int errorCode = parsejsonString.errorCode; if (errorCode == 0) { _context.Add(order); _context.SaveChanges(); return(Redirect(formUrl)); } else { return(Redirect("/Home")); } } else { var response = new HttpResponseMessage(HttpStatusCode.BadRequest); return(Redirect("/Home")); } }
// GET: Donate public ActionResult Index() { var donation = from d in db.Donation select new { d.DonationKey, d.Person.PersonFirstName, d.Person.PersonLastName, d.Person.PersonEmail, d.DonationAmount }; List <Donate> donate = new List <Donate>(); foreach (var d in donation) { Donate dnt = new Donate(); dnt.DonationKey = d.DonationKey; dnt.PersonFirstName = d.PersonFirstName; dnt.PersonLastName = d.PersonLastName; dnt.PersonEmail = d.PersonEmail; dnt.DonationAmount = d.DonationAmount; donate.Add(dnt); } return(View(donate)); }
public void Red(int id) { Donate dt = ctx.Donates.FirstOrDefault(x => x.DonateId == id); ctx.Donates.Remove(dt); ctx.SaveChanges(); }
public async Task <IActionResult> Edit(int id, [Bind("DonateId,Name,Value,Note,DonateTypeId,DateCreated,CustomerId")] Donate donate) { if (id != donate.DonateId) { return(NotFound()); } if (ModelState.IsValid) { try { context.Update(donate); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DonateExists(donate.DonateId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(PartialView(donate)); }
public IActionResult DonateCreate(NewDonateCreateViewModel model, [FromRoute] int Id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } model.CustomerId = ActiveUser.Instance.Customer.CustomerId; Donate d = new Donate(); d.DonateTypeId = ActiveUser.Instance.DonateTypeId; d.Name = model.Donate.Name; d.Note = model.Donate.Note; d.Value = model.Donate.Value; d.CustomerId = model.CustomerId; context.Donate.Add(d); try { context.SaveChanges(); return(RedirectToAction("ThankYou", "Donate")); } catch (DbUpdateException) { return(RedirectToAction("DonateCreate", "Donate")); } }
public IActionResult View(int id) { string constr = @"Server=LAPTOP-JHUBDUV5; Database=FoodDonation; Integrated Security= True"; SqlConnection conn = new SqlConnection(constr); string query = "SELECT * FROM Donate WHERE DonationId = " + id + ""; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); Donate donate = new Donate { DonationId = int.Parse(reader["DonationId"].ToString()), DonationTitle = reader["DonationTitle"].ToString(), FoodDescription = reader["FoodDescription"].ToString(), FoodWeight = double.Parse(reader["FoodWeight"].ToString()), FileUrl = reader["FileUrl"].ToString(), Location = reader["Location"].ToString(), ContactNo = reader["ContactNo"].ToString(), DonatedBy = int.Parse(reader["DonatedBy"].ToString()), DonationStatus = reader["DonationStatus"].ToString() }; reader.Close(); conn.Close(); ViewBag.deliveryMan = GetDeliveryManInformation(id); return(View(donate)); }
public IActionResult Index() { string constr = @"Server=LAPTOP-JHUBDUV5; Database=FoodDonation; Integrated Security= True"; SqlConnection conn = new SqlConnection(constr); //string query = "SELECT * FROM Donate"; string query = "SELECT * FROM Donate INNER JOIN Users ON Users.UserId = Donate.DonatedBy"; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); List <Donate> donationList = new List <Donate>(); while (reader.Read()) { Donate donate = new Donate { DonationId = int.Parse(reader["DonationId"].ToString()), DonationTitle = reader["DonationTitle"].ToString(), FoodDescription = reader["FoodDescription"].ToString(), FoodWeight = double.Parse(reader["FoodWeight"].ToString()), FileUrl = reader["FileUrl"].ToString(), Location = reader["Location"].ToString(), ContactNo = reader["ContactNo"].ToString(), DonatedBy = int.Parse(reader["DonatedBy"].ToString()), DonationStatus = reader["DonationStatus"].ToString(), DonorName = reader["UserName"].ToString(), }; donationList.Add(donate); } reader.Close(); conn.Close(); return(View(donationList)); }
public IActionResult Update(string id, Donate donIn) { // fetch Donate don; if (GetClaim(User, ClaimEnum.UserType) == "A") { don = _donateService.Get(id); } else { don = _donateService.Get(id, int.Parse(GetClaim(User, ClaimEnum.DeptNo))); } // not found (bc wrong dept or no donate record) if (don == null) { return(NotFound()); } // prevent change donIn.Id = don.Id; donIn.Accepted = false; donIn.Creator = don.Creator; donIn.DeptNo = don.DeptNo; _donateService.Update(id, donIn); return(NoContent()); }
public async Task <ActionResult <Donate> > PostDonate(Donate donate) { _context.Donates.Add(donate); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDonate", new { id = donate.Id }, donate)); }
public static bool UpdateDonate(Donate d) { NGOEntities e = new NGOEntities(); var item = e.Donates.Find(d.ID); item.DonateName = d.DonateName; item.DonateContent = d.DonateContent; item.StartDay = d.StartDay; item.EndDay = d.EndDay; item.DonateHide = d.DonateHide; item.CateID = d.CateID; if (d.StartDay <= DateTime.Now && d.EndDay >= DateTime.Now) { d.DonateStatus = 2; } else if (d.EndDay < DateTime.Now) { d.DonateStatus = 3; } else if (d.StartDay > DateTime.Now) { d.DonateStatus = 1; } if (e.SaveChanges() > 0) { return(true); } return(false); }
public async Task <IActionResult> PutDonate(int id, Donate donate) { if (id != donate.Id) { return(BadRequest()); } _context.Entry(donate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DonateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// handles /Complete, /Cancelled and /Failed postfix url parts when applied to the RegisterGuest or Dontate pages /// this is used so that distinct urls can be detected by the analytics /// </summary> /// <param name="contentRequest"></param> /// <returns></returns> public bool TryFindContent(PublishedContentRequest contentRequest) { // chop up the url string[] urlParts = contentRequest.Uri.GetAbsolutePathDecoded().Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); // we know hierarchy of register guest and donate pages, so expect only 2 url parts if (urlParts.Length == 2) { // only try processing if it ends with known string switch (urlParts[1]) { case "complete": case "cancelled": RegisterGuest registerGuest = (RegisterGuest)UmbracoContext.Current.ContentCache.GetSingleByXPath("//" + RegisterGuest.Alias); Donate donate = (Donate)UmbracoContext.Current.ContentCache.GetSingleByXPath("//" + Donate.Alias); if (urlParts[0] == registerGuest.Url.Trim('/')) { contentRequest.PublishedContent = registerGuest; return(true); } if (urlParts[0] == donate.Url.Trim('/')) { contentRequest.PublishedContent = donate; return(true); } break; } } return(false); }
public IActionResult StripeForm(NewDonateCreateViewModel model, [FromRoute] int Id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ViewBag.StripeKey = _paymentSettings.StripePublicKey; model.CustomerId = ActiveUser.Instance.Customer.CustomerId; Donate d = new Donate(); d.DonateTypeId = ActiveUser.Instance.DonateTypeId; d.Name = model.Donate.Name; d.Note = model.Donate.Note; d.Value = model.Donate.Value; d.CustomerId = model.CustomerId; context.Donate.Add(d); try { context.SaveChanges(); return(RedirectToAction("StripeCheckout", "Donate")); } catch (DbUpdateException) { return(RedirectToAction("StripeForm", "Donate")); } }
public async Task <IActionResult> Create(Donate donate) { if (!ModelState.IsValid) { return(View()); } if (donate.MainPhoto == null) { ModelState.AddModelError("Photo", "Photo should be selected"); return(View(donate)); } if (!donate.MainPhoto.ContentType.Contains("image/")) { ModelState.AddModelError("Photo", "File type is not valid"); return(View(donate)); } if (donate.MainPhoto.Length / 1024 / 1024 > 2) { ModelState.AddModelError("Photo", "File size can not be more than 2 mb"); return(View(donate)); } donate.MainImageUrl = await donate.MainPhoto.SaveAsync(_env.WebRootPath, "donates"); await _db.Donates.AddAsync(donate); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Donate))); }
public IActionResult MyDonations(string returnUrl = null) { Donate mydonation = new Donate(); var useremail = User.Identity.Name; var userdata = ctx.Users.Where(c => c.Email == useremail).ToList(); var isAdmin = ctx.UserRoles.Where(c => c.UserId == userdata[0].Id).ToList(); if (isAdmin.Count > 0) { var donatedata = ctx.Donate.ToList(); ViewBag.MyDonations = donatedata; return(View()); } else { var donatedata = ctx.Donate.Where(c => c.UserId == userdata[0].Id).ToList(); ViewBag.MyDonations = donatedata; return(View()); } //ViewBag.MyDonations = donatedata; //ViewData["ReturnUrl"] = returnUrl; //return View(); }
public ActionResult DeleteConfirmed(int id) { Donate donate = db.Donate.Find(id); db.Donate.Remove(donate); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult donateInProject([FromBody] Donate model) { var project = _db.Project.FirstOrDefault(p => p.Id == model.projectId); AddDonate(model, project); _db.SaveChanges(); return(Ok()); }
public ActionResult DonateDetail(int id) { Donate model = Repositories.GetDonateByID(id); ViewBag.cate = Repositories.GetAllCate(); ViewBag.ud = Repositories.GetUDByDonateID(id); return(View(model)); }
public void AddDonate(Donate model, Project project) { project.currentSum += model.purchase; project.progress = (int)(((float)project.currentSum / (float)project.requiredSum) * 100); var sponsor = FactorySponsor(model); project.Sponsors = CheckSponsor(model, project, sponsor); _db.Project.Update(project); }
public override ActionResult Index(RenderModel renderModel) { Donate model = (Donate)renderModel.Content; // if VendorTxCode can be found on the querystring, then get party guid from transaction table Guid vendorTxCode; if (Guid.TryParse(this.Request.QueryString["VendorTxCode"], out vendorTxCode)) { DonationRow donationRow = this.DatabaseContext.Database.Fetch <DonationRow>("SELECT TOP 1 * FROM wonderlandDonation WHERE VendorTxCode = @0", vendorTxCode).SingleOrDefault(); if (donationRow != null) { model.PartyHost = this.Members.GetPartyHost(donationRow.PartyGuid); model.DonationRow = donationRow; if (donationRow.Success) { return(this.View("Donate/Complete", model)); } else if (donationRow.Cancelled) { return(this.View("Donate/Cancelled", model)); } else { return(this.View("Donate/Failed", model)); } } else { return(this.View("Donate/UnknownTransaction", model)); } } Guid partyGuid; if (Guid.TryParse(this.Request.QueryString["partyGuid"], out partyGuid)) { model.PartyHost = this.Members.GetPartyHost(partyGuid); } // if a party wasn't found via the query string, then attempt to find party associated with the current login if (model.PartyHost == null && this.Members.IsLoggedInPartier()) { model.PartyHost = this.Members.GetPartyHost(((IPartier)this.Members.GetCurrentMember()).PartyGuid); } if (model.PartyHost != null) { return(this.View("Donate/Donate", model)); } // couldn't find a party host for this donation, so go to Macmillan return(this.View("Donate/Macmillan", model)); }
public Sponsors FactorySponsor(Donate model) { var sponsor = new Sponsors { Money = model.purchase, ProjectId = model.projectId, UserId = model.userId }; return(sponsor); }
/// <summary> /// Initializes a new instance of the <see cref="DonatesViewModel"/> class. /// </summary> /// <param name="serviceProxy">The data access service.</param> public DonatesViewModel(IDonatesDataAccessService serviceProxy) { _serviceProxy = serviceProxy; Donates = new ObservableCollection <Donate>(); SelectedDonate = new Donate(); RefreshCommand = new RelayCommand(GetDonates); SendDonateCommand = new RelayCommand <Donate>(SendDonate); SaveDonateCommand = new RelayCommand(SaveDonate); CancelCommand = new RelayCommand(Cancel); GetDonates(); }
public ActionResult <Donate> Create(Donate don) { // prevent change don.Accepted = false; don.Creator = GetClaim(User, ClaimEnum.FirstName); don.DeptNo = int.Parse(GetClaim(User, ClaimEnum.DeptNo)); // create _donateService.Create(don); return(CreatedAtRoute("GetDonate", new { id = don.Id.ToString() }, don)); }
public ActionResult UpdateDonate(Donate d) { if (Repositories.UpdateDonate(d) == true) { TempData["success"] = "Update donate successfully!"; } else { TempData["error"] = "Update donate failed!"; } return(RedirectToAction("DonateDetail", new { id = d.ID })); }
public ActionResult CreateDonate(Donate d) { if (Repositories.CreateDonate(d) == true) { TempData["success"] = "Create new donate successfully!"; } else { TempData["error"] = "Create new donate failed!"; } return(RedirectToAction("ListDonate")); }
public ActionResult Edit([Bind(Include = "DonateID,UserID,DonateTime,DonoteTotal,DonateContent,ExoressNumber,DonateState,ActivityID")] Donate donate) { if (ModelState.IsValid) { db.Entry(donate).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", donate.UserID); ViewBag.ActivityID = new SelectList(db.Activity, "ActivityID", "ActivityName", donate.ActivityID); return(View(donate)); }
public ActionResult <Donate> Get(string id) { User user = _userService.Find(User.Identity.Name); Donate don = _donateService.Get(id, user.DeptNo); if (don == null) { return(NotFound()); } return(don); }
public int CheckSponsor(Donate model, Project project, Sponsors sponsor) { if (_db.Sponsors.FirstOrDefault(p => (p.UserId == model.userId) && (p.ProjectId == model.projectId)) == null) { project.Sponsors++; _db.Sponsors.Add(sponsor); } else { _db.Sponsors.Update(sponsor); } return(project.Sponsors); }
public ActionResult GlnBagsOnay(int id, string KargoTakipNo) { Donate dd = ctx.Donates.FirstOrDefault(x => x.DonateId == id); dd.KargoTakipNo = KargoTakipNo; dd.VardiMi = true; ctx.SaveChanges(); string a = HttpContext.User.Identity.Name; Guid add = (Guid)Membership.GetUser(a).ProviderUserKey; return(RedirectToAction("Index", "Kullanici", new { @id = add })); }
public ActionResult Signup(Donate model) { try { if (ModelState.IsValid) { TestEntities db = new TestEntities(); Donordata nw = new Donordata(); nw.D_id = model.D_id; nw.Dname = model.Dname; nw.Daddress = model.Daddress; nw.Dusername = model.Dusername; nw.Dpassword = model.Dpassword; nw.Bbloodgroup = model.Bbloodgroup; nw.DPhone = model.DPhone; nw.Dthana = "A"; nw.Ddistrict = "Dhaka"; nw.DdonateDate = DateTime.Now; nw.Dactive = true; db.Donordatas.Add(nw); db.SaveChanges(); int latestdis = nw.D_id; UserProfile ur = new UserProfile(); ur.D_id = latestdis; ur.Dusername = model.Dusername; ur.Dpassword = model.Dpassword; db.UserProfiles.Add(ur); db.SaveChanges(); return(RedirectToAction("Login")); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(View(model)); }