Example #1
0
        public ActionResult Update(CCordinator cCordinator)
        {
            var Cordinator = this._contex.CCordinators.Single(p => p.Id == cCordinator.Id);

            ModelState["CCordinatorPassword"].Errors.Clear();
            ModelState["CCordinatorConfirmPassword"].Errors.Clear();
            cCordinator.CCordinatorConfirmPassword = Cordinator.CCordinatorPassword;
            cCordinator.CCordinatorPassword        = Cordinator.CCordinatorPassword;
            if (ModelState.IsValid)
            {
                if (cCordinator.CCordinatorImagefile != null)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(cCordinator.CCordinatorImagefile.FileName);
                    string Extantion = Path.GetExtension(cCordinator.CCordinatorImagefile.FileName);
                    fileName = fileName + DateTime.Now.Year + Extantion;
                    cCordinator.CCordinatorImagePath = "/Image/ccordinators/" + fileName;
                    fileName = Path.Combine(Server.MapPath("~/Image/ccordinators/"), fileName);
                    cCordinator.CCordinatorImagefile.SaveAs(fileName);
                }
                else
                {
                    cCordinator.CCordinatorImagePath = "/Image/user.jpg";
                }
                Cordinator.CCordinatorName            = cCordinator.CCordinatorName;
                Cordinator.CCordinatorPassword        = cCordinator.CCordinatorPassword;
                Cordinator.CCordinatorConfirmPassword = cCordinator.CCordinatorConfirmPassword;
                Cordinator.CCordinatorEmail           = cCordinator.CCordinatorEmail;
                Cordinator.CCordinatorPhone           = cCordinator.CCordinatorPhone;
                Cordinator.CCordinatorImagePath       = cCordinator.CCordinatorImagePath;
                this._contex.SaveChanges();
            }
            return(RedirectToAction("Index", "CCordinator"));
        }
Example #2
0
        public ActionResult Delete(int id)
        {
            try
            {
                int isExecuted = 0;

                CCordinator aCCordinator = this._contex.CCordinators.FirstOrDefault(dr => dr.Id == id);
                this._contex.CCordinators.Remove(aCCordinator);
                isExecuted = this._contex.SaveChanges();

                if (isExecuted > 0)
                {
                    ViewBag.AlertMsg = "Delete Successfully";
                }
                return(RedirectToAction("Index", "CCordinator"));
            }
            catch
            {
                return(RedirectToAction("Index", "CCordinator"));
            }
        }
Example #3
0
        public ActionResult New(
            [Bind(Exclude = "IsEmailVerified,ActivationCode")]
            CCordinator cCordinator)
        {
            ModelState["Id"].Errors.Clear();
            string Message = null;
            bool   Status  = false;

            if (!ModelState.IsValid)
            {
                Message = "Invalid Request";
                return(View());
            }
            else
            {
                if (cCordinator.Id == 0)
                {
                    if (IsEmailExist(cCordinator.CCordinatorEmail))
                    {
                        ModelState.AddModelError("EmailExist", "Email is already exist");
                        return(View());
                    }

                    #region Generate Activation Code

                    cCordinator.ActivationCode = Guid.NewGuid();

                    #endregion

                    #region Password Hashing

                    cCordinator.CCordinatorPassword        = Crypto.Hash(cCordinator.CCordinatorPassword);
                    cCordinator.CCordinatorConfirmPassword = Crypto.Hash(cCordinator.CCordinatorConfirmPassword);

                    #endregion

                    cCordinator.IsEmailVarified = false;

                    #region Save Data

                    _contex.CCordinators.Add(cCordinator);
                    _contex.SaveChanges();

                    #endregion

                    #region Send Email

                    var    url  = "/CCordinator/VarifyAccount/" + cCordinator.ActivationCode.ToString();
                    string link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, url);
                    Email.SendVarificationEmail(cCordinator.CCordinatorEmail, link);
                    Message = "Registration successfully done, Check your Email";
                    Status  = true;

                    #endregion
                }
            }

            ViewBag.Message = Message;
            ViewBag.Status  = Status;

            return(View());
        }