예제 #1
0
        public async Task <IActionResult> PostComment(IndvCompCommVM vm)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            //rating calculation
            vm.CompComment.Rating = (decimal)(vm.pmRating + vm.priceRating + vm.workManRating) / 3;

            //add comment to DB
            var returnId = await _companyRepo.AddComment(vm.CompComment);

            //update company rating in DB
            await _companyRepo.UpdateCompanyRating(vm.CompComment.CompID);

            //redirect to another action
            return(RedirectToAction("GetIndividualCompany", new { id = vm.CompComment.CompID }));
        }