Beispiel #1
0
        public void CreateFeedback(FeedbackViewModel feedbackViewModel)
        {
            Feedback feedback = feedbackViewModel.ToFeedback();

            int newFeedbackId = _feedbackRepository.Insert(feedback);

            if (newFeedbackId <= 0)
            {
                throw new Exception("Something went wrong while saving the new feedback");
            }
        }
Beispiel #2
0
        public void EditFeedback(FeedbackViewModel feedbackViewModel)
        {
            Feedback editedFeedback = feedbackViewModel.ToFeedback();

            if (editedFeedback == null)
            {
                throw new Exception($"The feedback with id {feedbackViewModel.Id} was not found!");
            }


            _feedbackRepository.Update(editedFeedback);
        }
        public async Task <IActionResult> Create([Bind("Description, Stars, Date, InterestPointId, VisitorId")] FeedbackViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var Feedback        = vm.ToFeedback();
                var createOperation = await _bo.CreateAsync(Feedback);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }
                return(OperationSuccess("The record was successfuly created"));
            }
            return(View(vm));
        }
Beispiel #4
0
        public void CreateFeedback(FeedbackViewModel feedbackViewModel)
        {
            List <Feedback> feedbacks = _feedbackRepository.GetAll().Where(x => x.Email == (feedbackViewModel.ToFeedback()).Email).ToList();

            if (feedbacks.Count == 3)
            {
                throw new Exception("Can't post anymore feedbacks you have already posted three");
            }
            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(feedbackViewModel.Email);

            if (!match.Success)
            {
                throw new Exception("Email is not in correct format");
            }
            Feedback feedback      = feedbackViewModel.ToFeedback();
            int      newFeedbackId = _feedbackRepository.Insert(feedback);

            if (newFeedbackId <= 0)
            {
                throw new Exception("An error occured while saving to db");
            }
        }