示例#1
0
        public BusinessProfileViewModel GetOwnBusinessProfileByID(string userName)
        {
            double fiveStar  = db.Review.Count(t => t.Rating == 5 && t.BusinessName == userName);
            double fourStar  = db.Review.Count(t => t.Rating == 4 && t.BusinessName == userName);
            double threeStar = db.Review.Count(t => t.Rating == 3 && t.BusinessName == userName);
            double twoStar   = db.Review.Count(t => t.Rating == 2 && t.BusinessName == userName);
            double oneStar   = db.Review.Count(t => t.Rating == 1 && t.BusinessName == userName);

            double totalStar      = (fiveStar + fourStar + threeStar + twoStar + oneStar);
            double weightedRating = (fiveStar * 5 + fourStar * 4 + threeStar * 3 + twoStar * 2 + oneStar * 1);
            double overallRating;
            string avgRating;

            if (totalStar != 0)
            {
                overallRating = weightedRating / totalStar;
                avgRating     = overallRating.ToString("0.00");
            }
            else
            {
                avgRating = "0";
            }

            // int total = db.Review.Count(t => t.Createdby == userName);
            BusinessProfileViewModel data = (from s in businessRepository.Get()
                                             where (s.Email == userName || s.BusinessName == userName)
                                             join d in businessCategoryRepository.Get() on s.CategoryId equals d.CategoryId
                                             select new BusinessProfileViewModel
            {
                BusinessId = s.BusinessId,
                BusinessName = s.BusinessName,
                Categories = d.CategoryName,
                UserName = s.UserName,
                About = s.About,
                ImageName = s.ImageName,
                City = s.City,
                // ClosedorMoved = s.ClosedorMoved,
                // OpeningHours = s.OpeningHours,
                Phone = s.Phone,
                Website = s.Website,
                Location = s.Location,
                Email = s.Email,
                OverallRating = avgRating,
                CategoryId = s.CategoryId,
                TotalReview = totalStar,
            }).SingleOrDefault();

            return(data);
        }
示例#2
0
        private void ConfigureViewModel(BusinessProfileViewModel model)
        {
            var context = ISDbContext.Create();
            GenericRepository <Business> firmContext = new GenericRepository <Business>(context);
            var firm = firmContext.GetById(User.Identity.GetUserId());

            model.Id             = firm.Id;
            model.FirmName       = firm.FirmName;
            model.Email          = firm.Email;
            model.Bulstat        = firm.Bulstat;
            model.Telephone      = firm.Telephone;
            model.Branches       = firm.Branches;
            model.AdditionalInfo = firm.AdditionalInfo;
            model.Services       = firm.Services;
            model.Image          = firm.Image;
        }
示例#3
0
        public async Task <ActionResult> Delete(BusinessProfileViewModel model)
        {
            ClearCookie();
            var context = ISDbContext.Create();

            ConfigureViewModel(model);
            var id = model.Id;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var firm = await UserManager.FindByIdAsync(id);

            var logins       = firm.Logins;
            var rolesForUser = await UserManager.GetRolesAsync(id);

            using (var transaction = context.Database.BeginTransaction())
            {
                foreach (var login in logins.ToList())
                {
                    await UserManager.RemoveLoginAsync(login.UserId, new UserLoginInfo(login.LoginProvider, login.ProviderKey));
                }

                if (rolesForUser.Count() > 0)
                {
                    foreach (var item in rolesForUser.ToList())
                    {
                        var result = await UserManager.RemoveFromRoleAsync(firm.Id, item);
                    }
                }

                await UserManager.DeleteAsync(firm);

                UserManager.Dispose();
                transaction.Commit();
                context.SaveChanges();
                return(View("Welcome"));
            }
        }
示例#4
0
        // GET: Profiles/Profile/5
        public IActionResult BusinessProfile(int id)
        {
            var business = _context.Business.Find(id);
            var users    = _context.Users.Where(c => c.BusinessId == id).ToList();
            var commutes = _context.Commute.Where(c => c.User.BusinessId == id).ToList();

            var model = new BusinessProfileViewModel
            {
                BusinessName        = business.BusinessName,
                BusinessCity        = business.BusinessCity,
                BusinessDescription = business.BusinessDescription,
                BusinessStreet      = business.BusinessStreet,
                BusinessZIP         = business.BusinessZIP,
                BusinessLink        = business.BusinessLink,
                Commutes            = commutes,
                Users = users
            };


            return(View(model));
        }
        public ActionResult ApproveRequest(int Businessid)
        {
            //MembershipCreateStatus createStatus;

            BusinessProfileViewModel businessProfiles = businessProfileService.GetRequestedBusniessbyId(Businessid);

            businessProfileService.UpdateBusinessProfile(businessProfiles, "Default.png");
            if (businessProfiles == null)
            {
                return(HttpNotFound());
            }

            string receiverMail, mailSubject, mailBody;

            receiverMail = businessProfiles.Email;
            mailSubject  = "reviewIt Registration";
            mailBody     = "Dear" + @businessProfiles.UserName + ",<br/><br/> Your request has been accepted.Please complete your registration. Url: http://localhost:59080/Account/BusinessRegister/" + @Businessid + "<br/><br/> Regards <br/><br/> reviewIt Authority";
            // [email protected] + " <br/><br/><br/> Password:"******" <br/><br/><br/> You can log in by using your user name or your Email and given password. If you want to change your password , log in and then click on Change password.<br/><br/><br/> Regards <br/><br/><br/> reviewIt Authority. ";
            mail.sendMail(receiverMail, mailSubject, mailBody);
            return(RedirectToAction("ApproveRequest"));
        }
示例#6
0
        public void CreateBusinessprofile(BusinessProfileViewModel businessVM)
        {
            business = new BusinessProfile
            {
                BusinessId   = businessVM.BusinessId,
                BusinessName = businessVM.BusinessName,
                Categories   = businessVM.Categories,
                About        = businessVM.About,
                City         = businessVM.City,
                // ClosedorMoved = businessVM.ClosedorMoved,
                // OpeningHours = businessVM.OpeningHours,
                Phone      = businessVM.Phone,
                Website    = businessVM.Website,
                Location   = businessVM.Location,
                Email      = businessVM.Email,
                UserName   = businessVM.UserName,
                CategoryId = businessVM.CategoryId,
                isBusiness = false,
                ImageName  = "Default.png",
            };

            businessRepository.Insert(business);
            db.SaveChanges();
        }
示例#7
0
        public BusinessProfileViewModel GetBusinessProfileByName(string name)
        {
            BusinessProfileViewModel data = (from s in businessRepository.Get()
                                             where s.BusinessName == name
                                             //join d in dropDownTypeRepository.Get() on s.DropDownTypeID equals d.DropDownTypeID
                                             select new BusinessProfileViewModel
            {
                BusinessId = s.BusinessId,
                BusinessName = s.BusinessName,
                UserName = s.UserName,
                ImageName = s.ImageName,
                Categories = s.Categories,
                About = s.About,
                City = s.City,
                // ClosedorMoved = s.ClosedorMoved,
                // OpeningHours = s.OpeningHours,
                Phone = s.Phone,
                Website = s.Website,
                Location = s.Location,
                Email = s.Email,
            }).SingleOrDefault();

            return(data);
        }
示例#8
0
        public BusinessProfileViewModel GetRequestedBusniessbyId(int businessID)
        {
            BusinessProfileViewModel data = (from s in businessRepository.Get()
                                             where s.BusinessId == businessID
                                             //join d in dropDownTypeRepository.Get() on s.DropDownTypeID equals d.DropDownTypeID
                                             select new BusinessProfileViewModel
            {
                BusinessId = s.BusinessId,
                BusinessName = s.BusinessName,
                Categories = s.Categories,
                About = s.About,
                City = s.City,
                // ClosedorMoved = businessVM.ClosedorMoved,
                // OpeningHours = businessVM.OpeningHours,
                Phone = s.Phone,
                Website = s.Website,
                Location = s.Location,
                Email = s.Email,
                UserName = s.UserName,
                CategoryId = s.CategoryId,
            }).SingleOrDefault();

            return(data);
        }
        public ActionResult IndividualBusinessProfile(string user)
        {
            BusinessProfileViewModel businessProfiles = businessProfileService.GetOwnBusinessProfileByID(user);

            return(View(businessProfiles));
        }
示例#10
0
        public JsonResult OverallRatingChartforBusiness(string user)
        {
            BusinessProfileViewModel chartData = businessProfileService.CountAllRating(user);

            return(Json(chartData, JsonRequestBehavior.AllowGet));
        }