Beispiel #1
0
        public JsonResult Sendcode(string emailreset)
        {
            Random code = new Random();

            randno = code.Next(10, 5000);
            int res = 50;

            DataBaseFuncController db = new DataBaseFuncController();

            var emails = db.GetAllActors();

            foreach (var element in emails)
            {
                if (emailreset == element.EMAIL)
                {
                    res = 11;
                    break;
                }
            }

            if (res == 11)
            {
                DateTime localDate = DateTime.Now;

                var actinfo = db.GetActorData(emailreset);

                S_ACTORS actcode = new S_ACTORS()
                {
                    CODE = randno, RESETTIME = localDate
                };
                db.UpdateActorReset(actinfo.ACTOR_ID, actcode);

                // Specify the from and to email address
                MailMessage mailMessage = new MailMessage
                                              ("*****@*****.**", emailreset);
                // Specify the email body
                mailMessage.Body = "Your Code to Reset Password is: " + randno.ToString();
                // Specify the email Subject
                mailMessage.Subject = "Reset Password";

                // No need to specify the SMTP settings as these
                // are already specified in web.config
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);

                // Finall send the email message using Send() method
                smtpClient.EnableSsl = true;
                smtpClient.Send(mailMessage);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult AllUserstoAssign(int id)
        {
            DataBaseFuncController db = new DataBaseFuncController();

            S_ACTORS act     = new S_ACTORS();
            PROJECT  project = new PROJECT();

            ProjectsUsersModel pum = new ProjectsUsersModel()
            {
                Users   = db.GetAllActors().ToList(),
                project = db.GetProjectID(id)
            };

            return(PartialView("../Shared/_ModalAssign", pum));
        }
Beispiel #3
0
        public JsonResult Register(string fname, string lname, string jobdesc, HttpPostedFileBase photo, string mobile, string role, string username, string password, string email)
        {
            byte[] photos = null;

            if (photo != null)
            {
                try
                {
                    string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(photo.FileName));
                    photo.SaveAs(path);

                    using (MemoryStream ms = new MemoryStream())
                    {
                        photo.InputStream.CopyTo(ms);
                        photos = ms.GetBuffer();
                    }

                    ViewBag.Message = "File uploaded successfully";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }

            try
            {
                S_ACTORS act = new S_ACTORS()
                {
                    FNAME = fname, LNAME = lname, JOB_DESC = jobdesc, MOBILE = Int32.Parse(mobile), AROLE = role, USERNAME = username, PASSWORD = password, EMAIL = email
                };
                DataBaseFuncController db = new DataBaseFuncController();

                var allactors = db.GetAllActors();


                foreach (var element in allactors)
                {
                    if (username == element.USERNAME)
                    {
                        return(Json(11, JsonRequestBehavior.AllowGet));
                    }
                }

                foreach (var element in allactors)
                {
                    if (email == element.EMAIL)
                    {
                        return(Json(12, JsonRequestBehavior.AllowGet));
                    }
                }

                if (db.AddActor(act) == "Done, Updated")
                {
                    var result = 0;
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var result = 1;
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.ToString(), JsonRequestBehavior.AllowGet));
            }
        }