Esempio n. 1
0
        public async Task <ActionResult> AddReview(AddReviewViewModel model)
        {
            try
            {
                if (model != null)
                {
                    using (ExploreDbContext context = new ExploreDbContext())
                    {
                        // Add the review to database
                        ReviewModel newReview = new ReviewModel();
                        newReview.createddate   = DateTime.Now;
                        newReview.dislikes      = 0; newReview.likes = 0;
                        newReview.overallrating = model.rating;
                        newReview.id            = Convert.ToString(Guid.NewGuid());
                        newReview.reviewmessage = model.review;
                        newReview.PositionId    = model.id;
                        newReview.UserId        = User.Identity.GetUserId();

                        context.AddReviewModel(newReview);
                        await context.SaveChangesAsync();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(RedirectToActionPermanent("Index", new { id = model.id })
                   );
        }
Esempio n. 2
0
        public ActionResult AddCompanyReview(CompanyViewModel companyModel)
        {
            try
            {
                //Get the Database Context
                ExploreDbContext dbContext = new ExploreDbContext();

                // Create Company
                CompanyModel newCompany = new CompanyModel()
                {
                    companyname = companyModel.CompanyName,
                    location = companyModel.Lat + "," + companyModel.Long,
                    overallrating = companyModel.rating, id = Guid.NewGuid().ToString()
                };

                newCompany =  dbContext.Company.Add(newCompany);

                // Create Job Position
                PositionModel newPosition = new PositionModel()
                {
                    id = Guid.NewGuid().ToString(),companyid = newCompany.id,
                    overallrating = companyModel.rating, positionname = companyModel.PositionName
                };

                newPosition = dbContext.AddPositionModel(newPosition);

                //Create Job Review
                ReviewModel newReview = new ReviewModel()
                {
                    id = Guid.NewGuid().ToString(), createddate = DateTime.Now,dislikes = 0, likes=0,
                    reviewmessage = companyModel.review, overallrating = companyModel.rating,UserId = User.Identity.GetUserId(),
                    PositionId = newPosition.id,totalreview = 1
                };

                newReview = dbContext.AddReviewModel(newReview);

                dbContext.SaveChanges();

            }
            catch (Exception ex)
            {
                //Suppress Exception           
            }
  

            return RedirectToActionPermanent("Index");
        }
Esempio n. 3
0
        public async Task <ActionResult> AddReview(CompanyViewModel model)
        {
            try
            {
                if (model != null)
                {
                    ExploreDbContext dbContext = new ExploreDbContext();

                    // Create Job Position
                    PositionModel jobPosition = new PositionModel();
                    jobPosition.companyid = model.id;  // Associate the Company for the position

                    jobPosition.id            = Convert.ToString(Guid.NewGuid());
                    jobPosition.overallrating = model.rating;
                    jobPosition.positionname  = model.PositionName;
                    jobPosition.totalrevies   = 1;

                    dbContext.AddPositionModel(jobPosition);

                    ReviewModel reviewMessage = new ReviewModel();
                    reviewMessage.id            = Convert.ToString(Guid.NewGuid());
                    reviewMessage.PositionId    = jobPosition.id;
                    reviewMessage.createddate   = DateTime.Now;
                    reviewMessage.likes         = 0; reviewMessage.dislikes = 0;
                    reviewMessage.reviewmessage = model.review;
                    reviewMessage.UserId        = User.Identity.GetUserId();

                    dbContext.AddReviewModel(reviewMessage);
                    await dbContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(RedirectToActionPermanent("Index", new { id = model.id }));
        }