public ActionResult DeleteConfirmed(int id)
        {
            FundRaiser fundRaiser = db.Fundraisers.Find(id);

            db.Fundraisers.Remove(fundRaiser);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "FundRaiserID,PhoneNumber,Email,Address,RelationshipToChild,RelationSpecification")] FundRaiser fundRaiser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fundRaiser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fundRaiser));
 }
        // GET: FundRaisers/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FundRaiser fundRaiser = db.Fundraisers.Find(id);

            if (fundRaiser == null)
            {
                return(HttpNotFound());
            }
            return(View(fundRaiser));
        }
        public void PopulateDB()
        {
            for (int i = 0; i < 20; i++)
            {
                FundRaiser fr = new FundRaiser
                {
                    Address   = "14bis",
                    BirthDate = DateTime.Today,
                    Email     = i + "@gmail.com",
                    FirstName = "Albert" + i,
                    LastName  = "Jack" + i,
                    //OrganizationName = "un enfant un espoir",
                    //RelationshipToChild = Referer.Nonprofit,
                    PhoneNumber = "34324234",
                };


                service.Add(fr);
                service.Commit();
            }
        }
        public ActionResult Create(FundRaiser fundRaiser)
        {
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            Trace.WriteLine(errors);

            //validate the cin field only
            //validate the full form throws an error
            if (ModelState.IsValidField(fundRaiser.CIN.ToString()))
            {
                //if he dosen't have an cin yet ,
                //add the cin to the entity
                //now the user is officially a fundraiser
                FundRaiser FundraiserToUpdate = service.GetById(fundRaiser.FundRaiserID);
                FundraiserToUpdate.CIN = fundRaiser.CIN;
                service.Update(FundraiserToUpdate);
                service.Commit();

                return(RedirectToAction("Create", "Kids", new { id = fundRaiser.FundRaiserID }));
            }

            ViewBag.errors = errors;
            return(View(fundRaiser));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Register(RegisterViewModel model, HttpPostedFileBase Image)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = new User
                    {
                        UserName = model.UserName,
                        Email    = model.Email,
                        Phone    = model.Phone,
                        Role     = model.Roles,
                        image    = Image.FileName
                    };
                    FundRaiserService service    = new FundRaiserService();
                    FundRaiser        fundRaiser = new FundRaiser()
                    {
                        Address     = model.Address,
                        BirthDate   = model.BirthDate,
                        Email       = model.Email,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        PhoneNumber = model.Phone,
                    };

                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        var token = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                        var confirmationLink = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = token }, protocol: Request.Url.Scheme);
                        UserManager.EmailService = new EmailService();
                        await UserManager.SendEmailAsync(user.Id,
                                                         "Confirm your account",
                                                         "Please confirm your account by clicking this link: <a href=\""
                                                         + confirmationLink + "\">link</a>");

                        return(RedirectToAction("SignalConfMail", "Account"));

                        //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        //Ends Here
                        var path2 = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName);
                        Image.SaveAs(path2);

                        //return RedirectToAction("Login", "Account");
                        service.Add(fundRaiser);
                        service.Commit();

                        return(RedirectToAction("Index", "Home"));
                    }
                    ViewBag.Name = new SelectList(ctx.Roles.ToList());
                    AddErrors(result);
                }
                var path = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName);
                Image.SaveAs(path);

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }