public BusinessLayerResult <Test_Master> RegisterTestMaster(TestMasterRegisterViewModel data)
        {
            // Kullanıcı user kontrolü
            // Kullanıcı e-posta kontrolü
            // Kayıt işlemi
            // Aktivasyon e-postası gönderimi

            User user = repo_user.Find(x => x.mail == data.mail);
            BusinessLayerResult <Test_Master> res = new BusinessLayerResult <Test_Master>();

            if (user != null)
            {
                if (user.mail == data.mail)
                {
                    res.AddError(Entities.Messages.ErrorMessageCode.EMailAlreadyExists, "E-Posta adresi kayıtlı.");
                }
            }
            else
            {
                int dbResult = Insert(new Test_Master()
                {
                    user_name        = data.user_name,
                    user_surname     = data.user_surname,
                    mail             = data.mail,
                    password         = data.password,
                    user_picturepath = "user_def.png",
                    user_regdate     = DateTime.Now,
                    score            = 0,
                    ActivateGuid     = Guid.NewGuid(),
                    notifications    = new List <Notification>()
                });

                if (dbResult >= 1)
                {
                    res.Result = Find(x => x.mail == data.mail);

                    string siteUri     = ConfigHelper.Get <string>("SiteRootUri");
                    string activateUri = $"{siteUri}/Home/TestMasterActivate/{res.Result.ActivateGuid}";
                    string body        = $"Merhaba yeni Test Master {res.Result.user_name}; !<br><br>Hesabını aktifleştirmek için <a href='{activateUri}' target='_blank'>tıklayınız</a>.";
                    MailHelper.SendMail(body, res.Result.mail, "Online Test Platform Hesap Aktifleştirme");
                }
            }
            return(res);
        }
示例#2
0
        public ActionResult TestMasterRegister(TestMasterRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                TestMasterManager tmm = new TestMasterManager();
                BusinessLayerResult <Test_Master> res = tmm.RegisterTestMaster(model);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(model));
                }

                OkViewModel ntfobj = new OkViewModel()
                {
                    Title          = "Kayıt Başarılı",
                    RedirectingUrl = "/Home/Index",
                };
                ntfobj.Items.Add("Lütfen e-posta adresinize gönderdiğimiz aktivasyon linkine tıklayarak hesabınızı aktive ediniz..");
                return(View("Ok", ntfobj));
            }
            return(View(model));
        }