Esempio n. 1
0
        public ActionResult User_Edit(Model_UserEdit model)
        {
            Tbl_Login _Login = db.Tbl_Login.Where(a => a.Login_ID == model.ID).SingleOrDefault();

            Tbl_User _User = _Login.Tbl_User;


            _Login.Login_Email      = model.Email;
            _Login.Login_Mobile     = model.Mobile;
            _User.User_GenderCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(Guid.Parse(model.Gender));
            _User.User_Name         = model.Name;
            _User.User_Family       = model.Family;

            db.Entry(_Login).State = EntityState.Modified;
            db.Entry(_User).State  = EntityState.Modified;

            if (Convert.ToBoolean(db.SaveChanges() > 0))
            {
                TempData["TosterState"]   = "success";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "عملیات با موفقیت انجام شد";

                return(RedirectToAction("index"));
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "عملیات با موفقیت انجام نشد";

                return(RedirectToAction("index"));
            }
        }
Esempio n. 2
0
        public ActionResult EditQuestion(Model_QuestionCreate model)
        {
            if (ModelState.IsValid)
            {
                Tbl_Question q = new Tbl_Question();

                if (model.ExamID != null)                                                           // ID
                {
                    q = db.Tbl_Question.Where(x => x.Question_ID == model.ExamID).FirstOrDefault(); // ID

                    if (q != null)
                    {
                        q.Question_Title        = model.Title;
                        q.Question_TypeCodeID   = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                        q.Question_GroupCodeID  = Rep_CodeGroup.Get_CodeIDWithGUID(model.Group);
                        q.Question_ResponseID   = Rep_CodeGroup.Get_CodeIDWithGUID(model.Response);
                        q.Question_Mark         = model.Mark;
                        q.Question_ModifiedDate = DateTime.Now;

                        db.Entry(q).State = EntityState.Modified;
                    }
                    else
                    {
                        return(HttpNotFound());
                    }
                }
                else
                {
                    q.Question_ERID         = model.ExamID;
                    q.Question_Title        = model.Title;
                    q.Question_TypeCodeID   = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                    q.Question_GroupCodeID  = Rep_CodeGroup.Get_CodeIDWithGUID(model.Group);
                    q.Question_ResponseID   = Rep_CodeGroup.Get_CodeIDWithGUID(model.Response);
                    q.Question_Mark         = model.Mark;
                    q.Question_Order        = db.Tbl_Question.Any() ? db.Tbl_Question.OrderByDescending(x => x.Question_Order).First().Question_Order : 1;
                    q.Question_CreationDate = q.Question_CreationDate = DateTime.Now;

                    db.Tbl_Question.Add(q);
                }

                if (Convert.ToBoolean(db.SaveChanges() > 0))
                {
                    TempData["TosterState"]   = "success";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterTitel"]   = "2";
                    TempData["TosterMassage"] = "عملیات با موفقیت انجام شد";

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View());
                }
            }

            return(View());
        }
Esempio n. 3
0
        public ActionResult Create(Model_ClassPlanCreate model)
        {
            if (ModelState.IsValid)
            {
                Tbl_ClassPlan _ClassPlan = new Tbl_ClassPlan
                {
                    CP_Guid           = Guid.NewGuid(),
                    CP_ClassID        = db.Tbl_Class.Where(x => x.Class_Guid.ToString() == model.Class).SingleOrDefault().Class_ID,
                    CP_TypeCodeID     = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type),
                    CP_Description    = model.Description,
                    CP_CostPerSession = model.CostPerSession,
                    CP_Location       = model.Location,
                    CP_Capacity       = model.Capacity,
                    CP_Time           = model.Time,
                    CP_SessionsLength = model.SessionsLength,
                    CP_StartDate      = DateConverter.ToGeorgianDateTime(model.StartDate),
                    CP_IsActive       = model.Activeness,
                    CP_CreationDate   = DateTime.Now,
                    CP_ModifiedDate   = DateTime.Now,
                };

                db.Tbl_ClassPlan.Add(_ClassPlan);

                if (Convert.ToBoolean(db.SaveChanges() > 0))
                {
                    TempData["TosterState"]   = "success";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "کلاس جدید با موفقیت ثبت شد";

                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["TosterState"]   = "error";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "کلاس جدید با موفقیت ثبت نشد";

                    return(View());
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
        public ActionResult QuestionEdit(Model_QuestionEdit model)
        {
            if (ModelState.IsValid)
            {
                Tbl_Question q = db.Tbl_Question.Where(x => x.Question_ID == model.ID).SingleOrDefault();

                if (q != null)
                {
                    q.Question_Title      = model.Title;
                    q.Question_TypeCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(Guid.Parse(model.Type));
                    q.Tbl_FormStep.FS_ID  = Convert.ToInt32(model.Step);

                    db.Entry(q).State = EntityState.Modified;

                    if (Convert.ToBoolean(db.SaveChanges() > 0))
                    {
                        TempData["TosterState"]   = "success";
                        TempData["TosterType"]    = TosterType.Maseage;
                        TempData["TosterMassage"] = "عملیات با موفقیت انجام شده";

                        return(RedirectToAction("Index", new { id = model.ID }));
                    }
                    else
                    {
                        TempData["TosterState"]   = "error";
                        TempData["TosterType"]    = TosterType.Maseage;
                        TempData["TosterMassage"] = "عملیات با موفقیت انجام نشده";

                        return(RedirectToAction("Index", new { id = model.ID }));
                    }
                }
                else
                {
                    return(HttpNotFound());
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Esempio n. 5
0
        public ActionResult CreateQuestion(Model_QuestionCreate model)
        {
            if (ModelState.IsValid)
            {
                Tbl_Question q = new Tbl_Question();
                q.Question_ERID        = model.ExamID;
                q.Question_Title       = model.Title;
                q.Question_TypeCodeID  = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                q.Question_GroupCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(model.Group);
                //Question_ResponseID = Rep_CodeGroup.Get_CodeIDWithGUID(model.Response);
                q.Question_Mark         = model.Mark;
                q.Question_Order        = db.Tbl_Question.Any() ? db.Tbl_Question.OrderByDescending(x => x.Question_Order).First().Question_Order : 1;
                q.Question_CreationDate = q.Question_ModifiedDate = DateTime.Now;

                Tbl_Response p1 = new Tbl_Response();
                p1.Response_QuestionID = q.Question_ID;
                p1.Response_TypeCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                p1.Response_Title      = model.Filepond1;
                p1.Response_Order      = db.Tbl_Response.Any(x => x.Response_QuestionID.Equals(q.Question_ID)) ? db.Tbl_Question.OrderByDescending(x => x.Question_Order).First().Question_Order : 1;

                //p1.Tbl_Question = q;

                Tbl_Response p2 = new Tbl_Response();
                p1.Response_QuestionID = q.Question_ID;
                p1.Response_TypeCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                p1.Response_Title      = model.Filepond2;
                p1.Response_Order      = db.Tbl_Response.Any(x => x.Response_QuestionID.Equals(q.Question_ID)) ? db.Tbl_Question.OrderByDescending(x => x.Question_Order).First().Question_Order : 1;

                Tbl_Response p3 = new Tbl_Response();
                p1.Response_QuestionID = q.Question_ID;
                p1.Response_TypeCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                p1.Response_Title      = model.Filepond3;
                p1.Response_Order      = db.Tbl_Response.Any(x => x.Response_QuestionID.Equals(q.Question_ID)) ? db.Tbl_Question.OrderByDescending(x => x.Question_Order).First().Question_Order : 1;

                Tbl_Response p4 = new Tbl_Response();
                p1.Response_QuestionID = q.Question_ID;
                p1.Response_TypeCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(model.Type);
                p1.Response_Title      = model.Filepond4;
                p1.Response_Order      = db.Tbl_Response.Any(x => x.Response_QuestionID.Equals(q.Question_ID)) ? db.Tbl_Question.OrderByDescending(x => x.Question_Order).First().Question_Order : 1;

                db.Tbl_Response.Add(p1);
                db.Tbl_Response.Add(p2);
                db.Tbl_Response.Add(p3);
                db.Tbl_Response.Add(p4);

                switch (Rep_CodeGroup.Get_CodeNameWithGUID(model.Response))
                {
                case "1":
                    q.Question_ResponseID = p1.Response_ID;
                    break;

                case "2":
                    q.Question_ResponseID = p2.Response_ID;
                    break;

                case "3":
                    q.Question_ResponseID = p3.Response_ID;
                    break;

                case "4":
                    q.Question_ResponseID = p4.Response_ID;
                    break;

                default:
                    break;
                }

                db.Entry(q).State = EntityState.Modified;

                if (Convert.ToBoolean(db.SaveChanges() > 0))
                {
                    TempData["TosterState"]   = "success";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "عملیات با موفقیت انجام شد";

                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["TosterState"]   = "error";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "عملیات با موفقیت انجام نشد";

                    return(RedirectToAction("Details"));
                }
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Esempio n. 6
0
        public ActionResult User_Add(Model_UserAdd model)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Dashboard", "Dashboard"));
            }

            if (!ModelState.IsValid)
            {
                return(View("Register", model));
            }


            Tbl_User  _User  = new Tbl_User();
            Tbl_Login _Login = new Tbl_Login();

            _Login.Login_Email      = model.Email;
            _Login.Login_CreateDate = DateTime.Now;
            _Login.Login_ModifyDate = DateTime.Now;
            _Login.Login_Guid       = Guid.NewGuid();
            _Login.Login_Mobile     = model.Mobile;
            _Login.Login_BaseRoleID = 2;


            _User.User_Guid         = Guid.NewGuid();
            _User.User_Name         = model.Name;
            _User.User_Family       = model.Family;
            _User.User_GenderCodeID = Rep_CodeGroup.Get_CodeIDWithGUID(Guid.Parse(model.Gender));

            _User.User_Birtday = DateTime.Now;

            var Salt              = Guid.NewGuid().ToString("N");
            var SaltPassword      = model.Password + Salt;
            var SaltPasswordBytes = Encoding.UTF8.GetBytes(SaltPassword);
            var SaltPasswordHush  = Convert.ToBase64String(SHA512.Create().ComputeHash(SaltPasswordBytes));

            _Login.Login_PasswordHash = SaltPasswordHush;
            _Login.Login_PasswordSalt = Salt;

            db.Tbl_User.Add(_User);

            _Login.Tbl_User = _User;

            db.Tbl_Login.Add(_Login);



            if (Convert.ToBoolean(db.SaveChanges() > 0))
            {
                //if (new SMSPortal().SendServiceable(model.Mobile, model.Mobile, model.Password, "", model.Name + " " + model.Family, SMSTemplate.Register) != "ارسال به مخابرات")
                //{
                //    TempData["TosterState"] = "warning";
                //    TempData["TosterType"] = TosterType.Maseage;
                //    TempData["TosterMassage"] = "خطا در ارسال پیامک";

                //    return RedirectToAction("Login");
                //};

                TempData["TosterState"]   = "success";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "ثبت نام با موفقیت انجام شد";

                return(RedirectToAction("index"));
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "ثبت نام با موفقیت انجام نشد";

                return(RedirectToAction("index"));
            }
        }
Esempio n. 7
0
        public ActionResult _Register(Model_Register model)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Dashboard", "Dashboard"));
            }

            if (!ModelState.IsValid)
            {
                return(View("Register", model));
            }


            Tbl_User _User = new Tbl_User();

            _User.User_Guid           = Guid.NewGuid();
            _User.User_Email          = model.Email;
            _User.User_FirstName      = model.Name;
            _User.User_lastName       = model.Family;
            _User.User_Mobile         = model.Mobile;
            _User.User_IdentityNumber = model.IdentityNumber;
            _User.User_RoleID         = 1;
            _User.User_GenderCodeID   = Rep_CodeGroup.Get_CodeIDWithGUID(Guid.Parse(model.Gender));

            var Salt              = Guid.NewGuid().ToString("N");
            var SaltPassword      = model.Password + Salt;
            var SaltPasswordBytes = Encoding.UTF8.GetBytes(SaltPassword);
            var SaltPasswordHush  = Convert.ToBase64String(SHA512.Create().ComputeHash(SaltPasswordBytes));

            _User.User_PasswordHash = SaltPasswordHush;
            _User.User_PasswordSalt = Salt;

            db.Tbl_User.Add(_User);

            Tbl_Wallet _Wallet = new Tbl_Wallet()
            {
                Wallet_Guid         = Guid.NewGuid(),
                Wallet_CreationDate = DateTime.Now,
                Wallet_ModifiedDate = DateTime.Now,
                Tbl_User            = _User
            };

            db.Tbl_Wallet.Add(_Wallet);

            if (Convert.ToBoolean(db.SaveChanges() > 0))
            {
                if (new SMSPortal().SendServiceable(model.Mobile, model.Mobile, model.Password, "", model.Name + " " + model.Family, SMSTemplate.Register) != "ارسال به مخابرات")
                {
                    TempData["TosterState"]   = "warning";
                    TempData["TosterType"]    = TosterType.Maseage;
                    TempData["TosterMassage"] = "خطا در ارسال پیامک";

                    return(RedirectToAction("Login"));
                }
                ;

                TempData["TosterState"]   = "success";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "ثبت نام با موفقیت انجام شد";

                return(RedirectToAction("Login"));
            }
            else
            {
                TempData["TosterState"]   = "error";
                TempData["TosterType"]    = TosterType.Maseage;
                TempData["TosterMassage"] = "ثبت نام با موفقیت انجام نشد";

                return(View());
            }
        }