コード例 #1
0
        public ActionResult Create([Bind(Include = "DID,FirstName,LastName,Email,Password,IsEmailVerified,ActivationCode,Street,Suburb,State,Postcode,Phone,Icon")] Donor donor)
        {
            if (ModelState.IsValid)
            {
                db.Donor.Add(donor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(donor));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "Item_ID,Item_Name,Category,Description,Estimated_Price,Icon")] Item item)
        {
            if (ModelState.IsValid)
            {
                db.Item.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "RID,RefugeeFName,RefugeeLName,AuthorityCode,Password,Street,Suburb,State,Email,Postcode,Phone,Family_Description,Icon")] Refugee refugee)
        {
            if (ModelState.IsValid)
            {
                refugee.Password = Crypto.Hash(refugee.Password);
                db.Refugee.Add(refugee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(refugee));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "DonationID,DID,Wish_List_ID,Item_Name,Donate_Date,Status")] Donation donation)
        {
            if (ModelState.IsValid)
            {
                db.Donation.Add(donation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DID          = new SelectList(db.Donor, "DID", "FirstName", donation.DID);
            ViewBag.Wish_List_ID = new SelectList(db.Wish_List, "Wish_List_ID", "Status", donation.Wish_List_ID);
            return(View(donation));
        }
コード例 #5
0
        public ActionResult ChangePassword([Bind(Include = "RID,AuthorityCode,RefugeeFName,RefugeeLName,Password,OldConfirmPassword,ConfirmNewPassword,NewPassword,Postcode,Email,Street,Suburb,State,Phone,Family_Description,Icon")] Refugee refugee)
        {
            newleavesdatabaseEntities1 db = new newleavesdatabaseEntities1();

            if (refugee.OldConfirmPassword != null && refugee.NewPassword != null && refugee.NewPassword != null)
            {
                if (string.Compare(Crypto.Hash(refugee.OldConfirmPassword), refugee.Password) == 0)
                {
                    if (ModelState.IsValid)
                    {
                        refugee.Password        = refugee.NewPassword;
                        refugee.Password        = Crypto.Hash(refugee.Password);
                        db.Entry(refugee).State = EntityState.Modified;
                        db.SaveChanges();
                        return(RedirectToAction("RefugeeDetailsAfter", new { code = User.Identity.Name }));
                    }
                }
                else
                {
                    ViewData["Non"] = "The old password didn't match";
                    return(View("ChangePassword", refugee));
                }
            }
            else
            {
                ViewData["Non"] = "Please fill all the boxes before submit.";
                return(View("ChangePassword", refugee));
            }



            return(View());
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "Wish_List_ID,RID,Item_ID,Create_Date,Hope_Delivery_Date,Status,Description,AuthorityCode")] Wish_List wish_List)
        {
            if (wish_List != null)
            {
                wish_List.Create_Date = DateTime.Now;
                wish_List.Status      = "Not delivered";
            }
            if (ModelState.IsValid)
            {
                db.Wish_List.Add(wish_List);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Item_ID = new SelectList(db.Item, "Item_ID", "Item_Name", wish_List.Item_ID);
            ViewBag.RID     = new SelectList(db.Refugee, "RID", "RefugeeFName", wish_List.RID);
            return(View(wish_List));
        }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "DID,FirstName,LastName,Email,Password,ConfirmPassword,IsEmailVerified,ActivationCode,Street,Suburb,State,Postcode,Phone,Icon")] Donor donor)
 {
     if (ModelState.IsValid)
     {
         donor.Password        = Crypto.Hash(donor.Password);
         donor.ConfirmPassword = Crypto.Hash(donor.ConfirmPassword);
         db.Entry(donor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DonorDetails", new { code = donor.Email }));
     }
     return(View(donor));
 }
コード例 #8
0
        public ActionResult Create([Bind(Include = "DonationID,DID,Wish_List_ID,Item_Name,Donate_Date,Status")] Donation donation, int id)
        {
            Wish_List wish = db.Wish_List.Find(id);

            wish.Status = "In processing";

            db.Entry(wish).State = EntityState.Modified;
            db.SaveChanges();
            //return RedirectToAction("Index");

            if (ModelState.IsValid)
            {
                db.Donation.Add(donation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DID          = new SelectList(db.Donor, "DID", "FirstName", donation.DID);
            ViewBag.Wish_List_ID = new SelectList(db.Wish_List, "Wish_List_ID", "Status", donation.Wish_List_ID);
            return(View(donation));
        }
コード例 #9
0
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] Donor donor)
        {
            bool   Status  = false;
            string message = "";

            //
            // Model Validation
            if (ModelState.IsValid)
            {
                #region //Email is already Exist
                var isExist = IsEmailExist(donor.Email);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exists");
                    return(View(donor));
                }
                #endregion

                #region Generate Activation Code
                donor.ActivationCode = Guid.NewGuid();
                #endregion


                donor.Password        = Crypto.Hash(donor.Password);
                donor.ConfirmPassword = Crypto.Hash(donor.ConfirmPassword);

                donor.IsEmailVerified = false;

                #region Save to Database
                using (newleavesdatabaseEntities1 dc = new newleavesdatabaseEntities1())
                {
                    dc.Donor.Add(donor);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(donor.Email, donor.ActivationCode.ToString());
                    message = "Registration successfully done. Account activation link " +
                              " has been sent to your email id:" + donor.Email;
                    Status = true;
                }
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(donor));
        }
コード例 #10
0
        public ActionResult Received(int id)
        {
            var username = User.Identity.Name;

            if (!string.IsNullOrEmpty(username))
            {
                var    user     = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username);
                string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName });
                ViewData.Add("FullName", fullName);
            }
            //delete the wishlist(make this record invisible)
            Wish_List wish_List = db.Wish_List.Find(id);

            wish_List.Status          = "Completed";
            db.Entry(wish_List).State = EntityState.Modified;
            db.SaveChanges();
            //change information in donation table
            //   Donation donation = wish_List.Donation.Where(d=>d.Wish_List_ID==id).FirstOrDefault();
            //  donation.Status = "Completed";
            //   db.Entry(donation).State = EntityState.Modified;
            //     db.SaveChanges();
            return(RedirectToAction("ShowWishList", new { code = User.Identity.Name }));
        }
コード例 #11
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (newleavesdatabaseEntities1 dc = new newleavesdatabaseEntities1())
            {
                dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid
                                                                // Confirm password does not match issue on save changes
                var v = dc.Donor.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }