예제 #1
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");
        }
예제 #2
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 }));
        }