示例#1
0
        //function to get individual company details
        public async Task <IActionResult> GetIndividualCompany(int id)
        {
            //get company details with comments from DB
            var results = await _companyRepo.GetCompanyWcommentsById(id);

            var vm = new IndvCompCommVM()
            {
                Company     = results,
                CompComment = new CompComment()
            };

            return(View("IndividualCompany", vm));
        }
示例#2
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 }));
        }