Beispiel #1
0
        public ActionResult Register(Customer customer)
        {
            if (ModelState.IsValid)
            {
                // Kullanıcı adı  kullanılmamış ise
                customer.ActivationCode = Guid.NewGuid();
                customer.isActive       = false;
                customer.CreatedDate    = DateTime.Now;
                customer.RemovedDate    = DateTime.Now;
                customer.ModifiedDate   = DateTime.Now;
                customer.RoleId         = 2;
                customer.ProfileImage   = "/Content/bay.png";
                // Kişinin kullanici adi varmi  ?
                bool userIsAlready = _customerServices.CheckCustomerByUsername(customer.UserName);
                bool userHasEmail  = _customerServices.CheckCustomerByEmail(customer.Email);
                if (userIsAlready == true)
                {
                    ModelState.AddModelError("", $"Bu {customer.UserName} kullanici adi kullaniliyor");
                }
                else if (userHasEmail == true)
                {
                    ModelState.AddModelError("", $"Bu {customer.Email} email kullaniliyor ");
                }
                else if (userHasEmail == false && userIsAlready == false)
                {
                    _customerServices.Register(customer);
                    return(RedirectToAction("Login", "Customer"));
                }
            }

            return(View(customer));
        }