public async Task <ActionResult <SubService> > Create(SubService value)
        {
            //SubService obj = new SubService(value);
            value.Service = await _service.GetById(value.ServiceId.ToString());

            _SubService.Add(value);
            Random generator = new Random();
            String password  = generator.Next(0, 999999).ToString("D6");
            Login  login     = new Login();

            login.Email      = "*****@*****.**";
            login.Role       = "Admin";
            login.RandomPass = password;

            loginInterface.Add(login);


            // it will be null
            //var testSubService = await _SubService.GetById(value.);

            // If everything is ok then:
            await _uow.Commit();

            // The product will be added only after commit
            // testProduct = await _productRepository.GetById(product.Id);

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <ActionResult <Admins> > Create(Admins value)
        {
            _Admins.Add(value);
            Random generator = new Random();
            string password  = generator.Next(0, 999999).ToString("D6");
            await sender.SendEmailAsync(value.Email, "Your account is successfully created", "Please use this <b>" + password + "</b> for login ");

            Login Login = new Login()
            {
                Email      = value.Email,
                Role       = value.Role,
                RandomPass = password,
                sentdate   = DateTime.Now.ToShortDateString()
            };

            _login.Add(Login);
            await _uow.Commit();


            return(RedirectToAction("Index"));
        }