示例#1
0
        public async Task <IActionResult> ForgotPassword(ForgotPasswordViewModel forgotPasswordViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(forgotPasswordViewModel));
            }

            var user = await _userManager.FindByEmailAsync(forgotPasswordViewModel.Email);

            if (forgotPasswordViewModel.Email == null)
            {
                return(RedirectToAction(nameof(forgotPasswordViewModel)));
            }

            var token = await _userManager.GeneratePasswordResetTokenAsync(user);

            var callback = Url.Action(nameof(ResetPassword), "AuthController", new { token, email = user.Email }, Request.Scheme);

            IEmailNotification <ForgotPassword> emailNotification = new EmailNotifaction <ForgotPassword>(Credientials);
            await emailNotification.Send(
                new ForgotPassword()
            {
                tutorname = user.Email, token = token
            },
                user.Email,
                "ForgotPassword",
                "ForgotPassword");

            //return Ok();
            //var message = new Message(new string[] { "*****@*****.**" }, "Reset password token", callback, null);
            //await _emailSender.SendEmailAsync(message);

            return(RedirectToAction(nameof(ForgotPasswordConfirmation)));
        }
        public async Task <IActionResult> Put([FromBody] ChangeOrderstatusDTO changeOrderstatusDTO)
        {
            ChangeOrderstatusModel ChangeOrder = new DTOMapper <ChangeOrderstatusDTO, ChangeOrderstatusModel>().Serialize(changeOrderstatusDTO);
            var ChangeOrderId = await _orderService.ChangeOrderStatus(ChangeOrder);

            IEmailNotification <OrderStatus> emailNotification = new EmailNotifaction <OrderStatus>(Credientials);

            await emailNotification.Send(
                new OrderStatus()
            {
                tutorname = ChangeOrderId.Name, ordernumber = ChangeOrderId.KeyId, orderstatus = ChangeOrderId.OrderStatus, color = "green"
            },
                ChangeOrderId.Email,
                "OrderStatus",
                "OrderStatus");

            return(Ok(ChangeOrderId));
        }
        public async Task <IActionResult> Post(OrderDTO model)
        {
            CreateOrderModel NewCreateOrder = new DTOMapper <OrderDTO, CreateOrderModel>().Serialize(model);
            var OrderResponse = await _orderService.AddOrders(NewCreateOrder);

            IEmailNotification <OrderPlaced> emailNotification = new EmailNotifaction <OrderPlaced>(Credientials);

            await emailNotification.Send(
                new OrderPlaced()
            {
                tutorname = OrderResponse.Name, ordernumber = OrderResponse.KeyId
            },
                OrderResponse.Email,
                "OrderPlaced",
                "OrderPlaced");

            return(Ok(OrderResponse));
        }