public IActionResult EditFeedbackPost(FeedbackViewModel feedbackViewModel)
 {
     if (!CharacterLength.CheckLength(feedbackViewModel.Message))
     {
         ViewData["Limit"] = CharacterLength.LimitNumber;
         return(View("CharacterLimit"));
     }
     if (!EmailValidation.CheckEmail(feedbackViewModel.Email))
     {
         ViewData["Limit"] = FeedbackNumberPerEmail.LimitNumber;
         return(View("InvalidMail"));
     }
     try
     {
         string email = _feedbackService.UpdateFeedback(feedbackViewModel);
         if (email == null)
         {
             return(View("FeedbackNumber"));
         }
         return(RedirectToAction("Details", new { id = feedbackViewModel.Id }));
     }
     catch
     {
         return(View("ExceptionView"));
     }
 }
示例#2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid && EmailValidation.CheckEmail(model.Email))
            {
                var user = new ApplicationUser {
                    UserName = model.Username, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("CreateWorkerForApplicationUser", "Worker", user));
                }
                AddErrors(result);
            }
            ViewBag.Email = "No E-mail exists with that address. Please enter valid e-mail.";
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#3
0
        public void CreteFeedback(FeedbackViewModel feedback)
        {
            List <Feedback> allFeedback = _feedbackRepository.GetFeedbackFromEmail(feedback.Email);

            if (!FeedbackNumberPerEmail.CalcFeedbackNumber(allFeedback))
            {
                throw new Exception($"Feedback count per mail excedeed! Only {FeedbackNumberPerEmail.maxLength} comments per email are allowed");
            }
            if (!CharacterLength.CheckLength(feedback.Message))
            {
                throw new Exception($"Feedback {CharacterLength.maxLength} characters limit excedeed!");
            }
            if (!EmailValidation.CheckEmail(feedback.Email))
            {
                throw new Exception("Invalid email format!");
            }
            int feedbackId = _feedbackRepository.Insert(feedback.ToFeedbackDomainModel());

            if (feedbackId <= 0)
            {
                throw new Exception("Feedback was not saved! Something went wrong!");
            }
        }
示例#4
0
        public void UpdateFeedback(FeedbackViewModel feedbackViewModel)
        {
            Feedback feedback = _feedbackRepository.GetById(feedbackViewModel.Id);

            if (feedback == null)
            {
                throw new Exception($"Feedback with id: {feedbackViewModel.Id} does not exist!");
            }
            List <Feedback> allFeedback = _feedbackRepository.GetFeedbackFromEmail(feedbackViewModel.Email).Where(x => x.Id != feedbackViewModel.Id).ToList();

            if (!FeedbackNumberPerEmail.CalcFeedbackNumber(allFeedback))
            {
                throw new Exception($"Feedback count per mail excedeed! Only {FeedbackNumberPerEmail.maxLength} comments per email are allowed");
            }
            if (!CharacterLength.CheckLength(feedback.Message))
            {
                throw new Exception($"Feedback {CharacterLength.maxLength} characters limit excedeed!");
            }
            if (!EmailValidation.CheckEmail(feedback.Email))
            {
                throw new Exception("Invalid email format!");
            }
            _feedbackRepository.UpdateEntity(feedbackViewModel.ToFeedbackDomainModel());
        }