Exemplo n.º 1
0
        public ActionResult UserEdit(int UserId = 0)
        {
            RegisteredUser registeredUser = RegisteredUserService.GetRegisteredUserById(UserId);

            if (registeredUser == null)
            {
                return(HttpNotFound());
            }
            RegisteredUserModel model = new RegisteredUserModel();

            model.EventId            = (int)registeredUser.EventId;
            model.FirstName          = registeredUser.FirstName;
            model.LastName           = registeredUser.LastName;
            model.Email              = registeredUser.Email;
            model.Country            = registeredUser.Country;
            model.DateOfRegistration = registeredUser.DateOfRegistration;
            model.IsDeleted          = registeredUser.IsDeleted;
            model.IsRegistered       = (bool)registeredUser.IsRegistered;
            model.ProfileImage       = registeredUser.ProfileImage;
            model.ProfileLink        = registeredUser.ProfileLink;
            var bsonresult = _mongodbHelper.GetUserDetailByEmail(registeredUser.Email, registeredUser.EventMaster.EventKey.ToString());

            if (bsonresult != null)
            {
                ViewBag.UserDocumentData = _mongodbHelper.ToJson(bsonresult);
            }
            ViewBag.FormCode = registeredUser.EventMaster.FormBuilderCode;
            return(View(model));
        }
Exemplo n.º 2
0
        // GET: PickupLocations
        public ActionResult Index()
        {
            var registeredUserService = new RegisteredUserService();
            var user = registeredUserService.GetRegisteredUser(this.User);

            var pickupLocations = db.PickupLocations.Include(p => p.Grower);

            return(View(pickupLocations.ToList()));
        }
Exemplo n.º 3
0
        public ActionResult Claim([Bind(Include = "id,product,comments")] Listing listing)
        {
            var id = listing.id;



            //if (ModelState.IsValid)
            //{
            var theComments = listing.comments;

            listing = db.Listings.FirstOrDefault(p => p.id == listing.id);

            var service = new RegisteredUserService();
            var user    = service.GetRegisteredUser(this.User);

            var foodBank = (from b in db.FoodBanks
                            where b.Id == user.FoodBankId
                            select b).FirstOrDefault();

            var growerUser = UserManager.FindById(listing.Grower.UserId);
            var grower     = db.Growers.First(x => x.UserId == growerUser.Id);
            var message    = new IdentityMessage
            {
                Destination = growerUser.PhoneNumber,
                Body        = $"Your listing of {listing.product} has been claimed by {foodBank.name}",
                Subject     = $"NW Harvest listing of {listing.product} has been claimed by {foodBank.name}"
            };

            var sendSMS = !string.IsNullOrWhiteSpace(growerUser.PhoneNumber) &&
                          growerUser.PhoneNumberConfirmed &&
                          (grower.NotificationPreference.ToLower().Contains("both") ||
                           grower.NotificationPreference.ToLower().Contains("text"));

            var sendEmail = growerUser.EmailConfirmed && (grower.NotificationPreference.ToLower().Contains("both") ||
                                                          grower.NotificationPreference.ToLower().Contains("email"));

            if (sendSMS)
            {
                UserManager.SmsService.SendAsync(message).Wait();
            }
            if (sendEmail)
            {
                UserManager.EmailService.SendAsync(message);
            }

            listing.FoodBank = foodBank;

            listing.comments  = theComments;
            listing.available = false;

            db.Entry(listing).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
            //}
            //ViewBag.Grower = new SelectList(db.Growers, "id", "name", listing.Grower.Id);
            //return View(listing);
        }
Exemplo n.º 4
0
        // GET: Listings/Create
        public ActionResult Create()
        {
            var registeredUserService = new RegisteredUserService();
            var user = registeredUserService.GetRegisteredUser(this.User);

            var grower = db.Growers.Where(g => g.Id == user.GrowerId).FirstOrDefault();
            ListingViewModel listingViewModel = new ListingViewModel(db, grower);

            return(View(listingViewModel));
        }
        public ActionResult Admindashboard()
        {
            DashboardModel model = new DashboardModel();

            model.TotalEvent      = EventService.GetAllEvents().Count();
            model.RegisteredUser  = RegisteredUserService.GetAllRegisteredUser().Count();
            model.TotalCustomers  = CustomerService.GetTotalCustomers();
            model.TotalPurchase   = CustomerService.GetTotalPurchase();
            model.ActiveCustomers = CustomerService.GetActiveCustomers();

            return(View(model));
        }
Exemplo n.º 6
0
        public void Remove_RegisteredUser_From_Database_Success_Test()
        {
            var data = new List <RegisteredUser>
            {
                new RegisteredUser()
                {
                    UserId = 1, EntryId = 1, Id = 1
                },
                new RegisteredUser()
                {
                    UserId = 2, EntryId = 2, Id = 2
                },
                new RegisteredUser()
                {
                    UserId = 3, EntryId = 3, Id = 3
                },
            }.AsQueryable();

            // Arrange
            var fakeDbSet = A.Fake <DbSet <RegisteredUser> >(o => o.Implements(typeof(IQueryable <RegisteredUser>)).Implements(typeof(IDbAsyncEnumerable <RegisteredUser>)));


            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).Provider).Returns(data.Provider);
            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).Expression).Returns(data.Expression);
            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).ElementType).Returns(data.ElementType);
            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).GetEnumerator()).Returns(data.GetEnumerator());

            var fakeContext         = A.Fake <RegisteredUserContext>();
            var fakeEntityDataModel = A.Fake <EntityDataModel>();

            A.CallTo(() => fakeContext.Context).Returns(fakeEntityDataModel);
            A.CallTo(() => fakeContext.RegisteredUsers).Returns(fakeDbSet);

            var registeredUserService = new RegisteredUserService(fakeContext);

            A.CallTo(() => fakeContext.RegisteredUsers.Remove(A <RegisteredUser> ._))
            .ReturnsLazily((RegisteredUser ru) => ru);

            var registeredUserToRemove = new RegisteredUser()
            {
                UserId = 1, EntryId = 1, Id = 1
            };

            // Act
            var registeredUser = registeredUserService.Remove(registeredUserToRemove);


            // Assert
            A.CallTo(() => fakeContext.Context.SaveChanges()).MustHaveHappened();
            Assert.AreEqual(1, registeredUser.UserId, "UserId Should be 1");
            Assert.AreEqual(1, registeredUser.EntryId, "EntryId Should be 1");
        }
Exemplo n.º 7
0
        // GET: Listings/Create
        public ActionResult Create()
        {
            var registeredUserService = new RegisteredUserService();
            var user = registeredUserService.GetRegisteredUser(this.User);

            ListingViewModel listingViewModel = new ListingViewModel();

            listingViewModel.Grower = db.Growers.Where(g => g.Id == user.GrowerId).FirstOrDefault();
            ViewBag.grower          = new SelectList(db.Growers, "id", "name");
            ViewBag.growerName      = "the grower";

            return(View(listingViewModel));
        }
Exemplo n.º 8
0
        public ActionResult Index(int CustomerId = 0)
        {
            ViewBag.CustomerId = CustomerId;
            DashboardModel model      = new DashboardModel();
            var            eventId    = RegisteredUserService.GetEventIdByCustomerId(Convert.ToInt32(Session["CustomerId"]));
            var            customerId = EventService.geteventdetailbyeventId(eventId);

            model.AvailableCredits = Convert.ToInt32(CustomerService.GetCustomerAvailableCredit(Convert.ToInt32(Session["CustomerId"])));
            //model.AvailableCredits = Convert.ToInt32(CustomerService.GetCustomerAvailableCredit(Convert.ToInt32(Session["CustomerId"])));
            model.TotalDeposit = CustomerService.GetTotalDeposit(Convert.ToInt32(Session["CustomerId"]));
            model.CreditsUsed  = Convert.ToInt32(RegisteredUserService.GetRegisteredUserByCustomerId(Convert.ToInt32(Session["CustomerId"])));
            return(View(model));
        }
Exemplo n.º 9
0
        public ActionResult Claim([Bind(Include = "id,product,comments")] Listing listing)
        {
            var id = listing.id;

            var theComments = listing.comments;

            listing = db.Listings.FirstOrDefault(p => p.id == listing.id);

            var service = new RegisteredUserService();
            var user    = service.GetRegisteredUser(this.User);

            var foodBank = (from b in db.FoodBanks
                            where b.Id == user.FoodBankId
                            select b).FirstOrDefault();
            var foodBankUser = UserManager.FindById(foodBank.UserId);

            var growerUser = UserManager.FindById(listing.Grower.UserId);
            var grower     = db.Growers.First(x => x.UserId == growerUser.Id);

            var sendSMS = !string.IsNullOrWhiteSpace(growerUser.PhoneNumber) &&
                          growerUser.PhoneNumberConfirmed &&
                          (grower.NotificationPreference.ToLower().Contains("both") ||
                           grower.NotificationPreference.ToLower().Contains("text"));

            if (sendSMS)
            {
                var textMessage = CreateSMSMessage(growerUser, foodBankUser, listing);

                UserManager.SmsService.SendAsync(textMessage).Wait();
            }

            var sendEmail = growerUser.EmailConfirmed &&
                            (grower.NotificationPreference.ToLower().Contains("both") ||
                             grower.NotificationPreference.ToLower().Contains("email"));

            if (sendEmail)
            {
                var emailMessage = CreateEmailMessage(growerUser, foodBankUser, listing);

                UserManager.EmailService.SendAsync(emailMessage);
            }

            listing.FoodBank = foodBank;

            listing.comments  = theComments;
            listing.available = false;

            db.Entry(listing).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
        public ActionResult GetEventDetails(string EventKey, string referralid = "")
        {
            var eventdata = EventService.GetEventByKey(EventKey);

            if (referralid != "")
            {
                var visitorstate = new VisitorState();
                visitorstate.IPaddress   = "";
                visitorstate.CreatedDate = DateTime.Now;
                visitorstate.ReferralId  = Convert.ToInt32(referralid);
                RegisteredUserService.InsertVisitorState(visitorstate);
            }
            return(Json(new { success = true, form = eventdata.FormBuilderCode, eventid = eventdata.EventId, buttonUrl = eventdata.ButtonURL, fbButtonUrl = eventdata.FbButtonURL, domainname = eventdata.DomainName }));
        }
Exemplo n.º 11
0
        public EditTeam CreateEditTeam(int?id)
        {
            Team team;

            using (var context = new TeamContext())
            {
                var service = new TeamService(context);
                team = service.GetAll().SingleOrDefault(t => t.Id == id);
            }
            EditTeam editTeamViewModel = new EditTeam();

            editTeamViewModel.team = team;
            RaceEntry raceEntry;

            using (var context = new RaceEntryContext())
            {
                var service = new RaceEntryService(context);
                raceEntry = service.GetByTeamId(team.Id);
            }
            using (var context = new RaceEventContext())
            {
                editTeamViewModel.raceEvent = context.RaceEvents.SingleOrDefault(r => r.Id == raceEntry.RaceId);
            }
            editTeamViewModel.registeredUsers = new List <RegisteredUser>();
            editTeamViewModel.users           = new List <User>();
            IEnumerable <int> registeredUserIds;

            using (var context = new TeamCrewRegisteredUserContext())
            {
                var service = new TeamCrewRegisteredUserService(context);
                registeredUserIds = service.GetAllregisteredUserIdsByTeamId(team.Id);
            }
            using (var context = new RegisteredUserContext())
            {
                var RUservice   = new RegisteredUserService(context);
                var userService = new UserService(new UserContext());
                foreach (int rUserId in registeredUserIds)
                {
                    int            userId         = RUservice.GetUserIdById(rUserId);
                    RegisteredUser registeredUser = RUservice.GetById(rUserId);
                    User           user           = userService.GetAll().SingleOrDefault(u => u.Id == userId);
                    editTeamViewModel.registeredUsers.Add(registeredUser);
                    editTeamViewModel.users.Add(user);
                }
            }
            return(editTeamViewModel);
        }
Exemplo n.º 12
0
        public ActionResult ExporttoExcel()
        {
            var exportreferraluserdetails = RegisteredUserService.ZoomUserReport(Convert.ToInt32(Session["EventId"]), Convert.ToInt32(Session["CustomerId"]), Convert.ToString(TempData["SearchTitle"]));
            List <ZoomUserExportModel> ExportZoomUserReportModel = new List <Models.ZoomUserExportModel>();

            foreach (var item in exportreferraluserdetails)
            {
                var model = new ZoomUserExportModel();
                model.Name               = item.FirstName + item.LastName;
                model.Email              = item.Email;
                model.EventName          = item.EventName;
                model.Country            = item.Country;
                model.DateOfRegistration = item.DateOfRegistration;
                model.Company            = item.CRM_CompanyName;
                model.JobDesignation     = item.CRM_JobTitle;
                model.Source             = item.Source;
                model.SeniorityLevel     = item.SeniorityLevel;
                model.PrimaryJob         = item.PrimaryJobFunction;
                model.NatureofBusiness   = item.NatureOfBusiness;
                model.Checbox1           = (Convert.ToBoolean(item.OptInEmail)) ? "Yes" : "No";
                model.Checbox2           = (Convert.ToBoolean(item.OptInPhone)) ? "Yes" : "No";
                model.Checbox3           = (Convert.ToBoolean(item.OptInDirectEmail)) ? "Yes" : "No";
                model.Checbox4           = (Convert.ToBoolean(item.OptInDGMEvents)) ? "Yes" : "No";
                ExportZoomUserReportModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ExportZoomUserReportModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=Registereduser.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
        public void GetAllEntryIdsByUserId_Returns_two_EntryIds_Successfuly_Test()
        {
            var data = new List <RegisteredUser>
            {
                new RegisteredUser()
                {
                    UserId = 1, EntryId = 1, Id = 1
                },
                new RegisteredUser()
                {
                    UserId = 1, EntryId = 2, Id = 2
                },
                new RegisteredUser()
                {
                    UserId = 2, EntryId = 3, Id = 3
                },
            }.AsQueryable();

            // Arrange
            var fakeDbSet = A.Fake <DbSet <RegisteredUser> >(o => o.Implements(typeof(IQueryable <RegisteredUser>)).Implements(typeof(IDbAsyncEnumerable <RegisteredUser>)));


            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).Provider).Returns(data.Provider);
            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).Expression).Returns(data.Expression);
            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).ElementType).Returns(data.ElementType);
            A.CallTo(() => ((IQueryable <RegisteredUser>)fakeDbSet).GetEnumerator()).Returns(data.GetEnumerator());

            var fakeContext         = A.Fake <RegisteredUserContext>();
            var fakeEntityDataModel = A.Fake <EntityDataModel>();

            A.CallTo(() => fakeContext.Context).Returns(fakeEntityDataModel);
            A.CallTo(() => fakeContext.RegisteredUsers).Returns(fakeDbSet);

            var registeredUserService = new RegisteredUserService(fakeContext);

            // Act
            var entryIds = registeredUserService.GetAllEntryIdsByUserId(1).ToList();

            // Assert
            A.CallTo(() => fakeContext.Context.SaveChanges()).MustNotHaveHappened();
            Assert.AreEqual(2, entryIds.Count(), "Count should be 2");
            Assert.AreEqual(1, entryIds.First(), "EntryId Should be 1");
        }
Exemplo n.º 14
0
        public ActionResult Create(ListingViewModel listingViewModel)
        {
            var service = new RegisteredUserService();
            var user    = service.GetRegisteredUser(this.User);

            var saveListing = new Listing();

            saveListing.Grower = (from b in db.Growers
                                  where b.Id == user.GrowerId
                                  select b).FirstOrDefault();

            saveListing.PickupLocation = (from b in db.PickupLocations
                                          where b.id.ToString() == listingViewModel.SavedLocationId
                                          select b).FirstOrDefault();

            saveListing.product        = listingViewModel.product;
            saveListing.qtyClaimed     = listingViewModel.qtyClaimed;
            saveListing.qtyOffered     = listingViewModel.qtyOffered;
            saveListing.qtyLabel       = listingViewModel.qtyLabel;
            saveListing.harvested_date = listingViewModel.harvested_date;
            saveListing.expire_date    = listingViewModel.expire_date;
            saveListing.cost           = listingViewModel.cost;
            saveListing.available      = true;
            saveListing.comments       = listingViewModel.comments;
            saveListing.FoodBank       = listingViewModel.FoodBank;
            saveListing.location       = "";
            saveListing.qtyClaimed     = 0;

            CheckListingForErrors(saveListing);

            if (ModelState.IsValid)
            {
                db.Listings.Add(saveListing);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            //Get pickup locations.
            listingViewModel.Grower = saveListing.Grower;
            listingViewModel.PopulatePickupLocations(db);

            return(View(listingViewModel));
        }
Exemplo n.º 15
0
        public ActionResult Index(int EventId = 0, int UserId = 0, int usercount = 1)
        {
            ViewBag.EventId  = EventId;
            model.ReferralId = UserId;
            if (EventId > 0)
            {
                Session["EventId"]    = EventId;
                model.EventId         = EventId;
                model.RegisteredUser  = RegisteredUserService.GetRegisteredUserByEventId(EventId).Count();
                ViewBag.TotalCount    = RegisteredUserService.GetRegisteredUserByEventId(EventId).Count();
                model.Linkedinusers   = RegisteredUserService.GetLinkedinUserByEventId(EventId).Count();
                model.Facebookusers   = RegisteredUserService.GetFacebookUserByEventId(EventId).Count();
                model.Creditrequired  = RegisteredUserService.Creditrequired(EventId);
                model.TotalReferences = RegisteredUserService.GetReferralIByEventId(EventId);
                model.EventName       = RegisteredUserService.GetEventNamebyEventId(EventId);
                model.EventStartDate  = RegisteredUserService.GetStartdatebyEventId(EventId);
                model.EventEndDate    = RegisteredUserService.GetEnddatebyEventId(EventId);
                model.Image           = RegisteredUserService.GetEventlogobyEventId(EventId);
                model.ButtonURL       = EventService.GetEventById(EventId).ButtonURL;
            }
            if (UserId == 0)
            {
                model.usercount = 1;
            }
            int CustomerId = Convert.ToInt32(Session["CustomerId"]);

            ViewBag.CustomerId = CustomerId;
            var eventdata = EventService.geteventdetailbyeventId(EventId);

            ViewBag.Customers = eventdata;
            var eventuser = EventService.GetEventusersByCustomerId(Convert.ToInt32(Session["CustomerId"]));

            if (eventuser != null)
            {
                ViewBag.EventUserData = "false";
            }
            else
            {
                ViewBag.EventUserData = "true";
            }
            return(View(model));
        }
        public ActionResult ExporttoExcel()
        {
            int CustomerId        = Convert.ToInt32(Session["CustomerId"]);
            var exportuserdetails = RegisteredUserService.Eventwiseuser(Convert.ToString(TempData["SearchTitle"]), "", "", Convert.ToInt32(TempData["Event"]), CustomerId, 0);
            List <ExportUserDetailsModel> ExportUserDetailsModel = new List <Models.ExportUserDetailsModel>();

            foreach (var item in exportuserdetails)
            {
                var model = new ExportUserDetailsModel();
                //model.EventId = item.EventId;
                model.Id                 = item.UserId;
                model.CRM_Id             = item.CRM_RegistrationId;
                model.Name               = item.FirstName + " " + item.LastName;
                model.ReferredBy         = item.ReferredBy;
                model.Email              = item.Email;
                model.ReferralCount      = item.ReferralCount;
                model.VisitorCount       = item.VisitorCount;
                model.DateOfRegistration = item.DateOfRegistration;
                model.EventName          = item.EventName;
                model.CompanyName        = item.CRM_CompanyName;
                model.JobTitle           = item.CRM_JobTitle;
                ExportUserDetailsModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ExportUserDetailsModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=Registereduser.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(RedirectToAction("Index"));
        }
 public ActionResult Index(int EventId = 0, int UserId = 0, int usercount = 0)
 {
     ViewBag.EventId  = EventId;
     model.ReferralId = UserId;
     if (EventId > 0)
     {
         Session["EventId"]   = EventId;
         model.EventId        = EventId;
         ViewBag.TotalCount   = RegisteredUserService.GetRegisteredUserByEventId(EventId).Count();
         model.RegisteredUser = RegisteredUserService.GetRegisteredUserByEventId(EventId).Count();
         //model.Creditrequired = RegisteredUserService.Creditrequired(EventId);
         model.TotalReferences = RegisteredUserService.GetReferralId();
         model.EventName       = RegisteredUserService.GetEventNamebyEventId(EventId);
         model.EventStartDate  = RegisteredUserService.GetStartdatebyEventId(EventId);
         model.EventEndDate    = RegisteredUserService.GetEnddatebyEventId(EventId);
         model.Image           = RegisteredUserService.GetEventlogobyEventId(EventId);
         model.usercount       = 0;
     }
     return(View(model));
 }
Exemplo n.º 18
0
        public ActionResult Create(ListingViewModel listing)
        {
            var service = new RegisteredUserService();
            var user    = service.GetRegisteredUser(this.User);

            var grower = (from b in db.Growers
                          where b.Id == user.GrowerId
                          select b).FirstOrDefault();
            var pickupLocation = (from b in db.PickupLocations
                                  where b.id.ToString() == listing.SavedLocationId
                                  select b).FirstOrDefault();

            listing.Grower         = grower;
            listing.available      = true;
            listing.PickupLocation = pickupLocation;

            var saveListing = new Listing();

            saveListing.product        = listing.product;
            saveListing.qtyClaimed     = listing.qtyClaimed;
            saveListing.qtyOffered     = listing.qtyOffered;
            saveListing.qtyLabel       = listing.qtyLabel;
            saveListing.harvested_date = listing.harvested_date;
            saveListing.expire_date    = listing.expire_date;
            saveListing.cost           = listing.cost;
            saveListing.available      = listing.available;
            saveListing.comments       = listing.comments;
            saveListing.Grower         = listing.Grower;
            saveListing.FoodBank       = listing.FoodBank;


            if (ModelState.IsValid)
            {
                db.Listings.Add(saveListing);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            //ViewBag.grower = new SelectList(db.Growers, "id", "name", listing.Grower.Id);
            return(View(listing));
        }
Exemplo n.º 19
0
        public ActionResult GetRegisteredUser(int UserId)
        {
            var registereduser = RegisteredUserService.GetRegisteredUserById(UserId);

            if (registereduser == null)
            {
                return(Json(new { success = false }));
            }

            RegisteredUserModel model = new RegisteredUserModel();

            model.UserId       = registereduser.UserId;
            model.EventId      = (int)registereduser.EventId;
            model.FirstName    = registereduser.FirstName;
            model.LastName     = registereduser.LastName;
            model.Email        = registereduser.Email;
            model.Country      = registereduser.Country;
            model.ProfileLink  = registereduser.ProfileLink;
            model.ProfileImage = registereduser.ProfileImage;
            return(Json(new { success = true, user = model }));
        }
Exemplo n.º 20
0
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha, string Domain, int Event, int ReferralId)
        {
            Domain      = Domain.Trim().ToLower();
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            int CustomerId = Convert.ToInt32(Session["CustomerId"]);

            List <ZoomUserReportModel> refrraluserslist = new List <ZoomUserReportModel>();
            var regusers = RegisteredUserService.ZoomUserReport(Event, CustomerId, SearchTitle);

            foreach (var user in regusers)
            {
                ZoomUserReportModel model = new ZoomUserReportModel();
                model.UserId              = user.UserId;
                model.EventId             = user.EventId;
                model.EventName           = user.EventName;
                model.ProfileImage        = user.ProfileImage;
                model.CRM_CompanyName     = user.CRM_CompanyName;
                model.CRM_JobTitle        = user.CRM_JobTitle;
                model.ReferralId          = user.ReferalId;
                model.FirstName           = user.FirstName;
                model.LastName            = user.LastName;
                model.Email               = user.Email;
                model.Country             = user.Country;
                model.DateOfRegistration  = user.DateOfRegistration;
                model.ReferredBy          = user.RefferedBy;
                model.Source              = user.Source;
                model.SeniorityLevel      = user.SeniorityLevel;
                model.PrimaryJob          = user.PrimaryJobFunction;
                model.NatureofBusiness    = user.NatureOfBusiness;
                model.TopicOfInterest     = user.TopicOfIntrest;
                model.RegisteredForGlobal = user.AreyouRegistered;
                model.Checbox1            = (Convert.ToBoolean(user.OptInEmail)) ? "Yes" : "No";
                model.Checbox2            = (Convert.ToBoolean(user.OptInPhone)) ? "Yes" : "No";
                model.Checbox3            = (Convert.ToBoolean(user.OptInDirectEmail)) ? "Yes" : "No";
                model.Checbox4            = (Convert.ToBoolean(user.OptInDGMEvents)) ? "Yes" : "No";
                refrraluserslist.Add(model);
            }
            return(refrraluserslist);
        }
Exemplo n.º 21
0
 public ActionResult Create(int userId, int entryId, int teamId, List <RegisteredUser> regUsers)
 {
     if (userId != 0)
     {
         int regUserId;
         using (var context = new RegisteredUserContext())
         {
             var service = new RegisteredUserService(context);
             regUserId = service.GetIdByUserIdAndEntryId(userId, entryId);
         }
         using (var context = new TeamCrewRegisteredUserContext())
         {
             var service = new TeamCrewRegisteredUserService(context);
             if (!regUsers.Select(u => u.Id).Contains(regUserId))
             {
                 service.Add(regUserId, teamId);
             }
         }
         return(RedirectToAction("Index", "Home"));
     }
     return(View(userId));
 }
        public ActionResult Index(int EventId = 0)
        {
            DashboardModel model    = new DashboardModel();
            var            customer = CustomerService.GetCustomerById(Convert.ToInt32(Session["CustomerId"]));

            model.TotalEvent = CustomerService.GetEventsCount(customer.CustomerId);
            var eventId    = RegisteredUserService.GetEventIdByCustomerId(Convert.ToInt32(Session["CustomerId"]));
            var customerId = EventService.geteventdetailbyeventId(eventId);

            if (eventId == 0)
            {
                model.AvailableCredits = Convert.ToInt32(CustomerService.GetCustomerAvailableCredit(Convert.ToInt32(Session["CustomerId"])));
            }
            else
            {
                model.AvailableCredits = Convert.ToInt32(CustomerService.GetCustomerAvailableCredit(customerId));
            }

            model.RegisteredUser = RegisteredUserService.GetRegisteredUserByCustomerId(customer.CustomerId);
            model.LinkedinUser   = RegisteredUserService.GetLinkedinUserByCustomerId(customer.CustomerId);
            model.FacebookUser   = RegisteredUserService.GetFacebookUserByCustomerId(customer.CustomerId);
            model.Name           = CustomerService.GetCustomerByName(customer.FirstName, customer.LastName);
            if (model.Name != null)
            {
                ViewBag.Name = model.Name;
            }
            var eventuser = EventService.GetEventusersByCustomerId(Convert.ToInt32(Session["CustomerId"]));

            if (eventuser != null)
            {
                ViewBag.EventUserData = "false";
            }
            else
            {
                ViewBag.EventUserData = "true";
            }
            // SendMailService.SendMail("*****@*****.**", "Test", "Test");
            return(View(model));
        }
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha, string Domain, int Event, int ReferralId)
        {
            Domain      = Domain.Trim().ToLower();
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            int CustomerId = Convert.ToInt32(Session["CustomerId"]);

            List <UserMasterModel> userlist = new List <UserMasterModel>();
            var regusers = RegisteredUserService.Eventwiseuser(SearchTitle, Alpha, Domain, Event, CustomerId, ReferralId);

            foreach (var user in regusers)
            {
                UserMasterModel model = new UserMasterModel();
                model.UserId             = user.UserId;
                model.FirstName          = user.FirstName;
                model.LastName           = user.LastName;
                model.ReferredBy         = user.ReferredBy;
                model.Email              = user.Email;
                model.Country            = user.Country;
                model.DomainName         = user.DomainName;
                model.EventId            = user.EventId;
                model.EventName          = user.EventName;
                model.EventStartDate     = user.EventStartDate;
                model.EventEndDate       = user.EventEndDate;
                model.DateOfRegistration = user.DateOfRegistration;
                model.ReferralCount      = Convert.ToInt32(user.ReferralCount);
                model.ConnectionCount    = Convert.ToInt32(user.ConnectionCount);
                model.ProfileImage       = user.ProfileImage;
                model.visitorcount       = user.VisitorCount;
                model.CRM_CompanyName    = user.CRM_CompanyName;
                model.CRM_JobTitle       = user.CRM_JobTitle;
                model.CRM_RegistrationId = user.CRM_RegistrationId;
                model.Source             = user.Source;
                userlist.Add(model);
            }
            ViewBag.TotalCount = RegisteredUserService.GetRegisteredUserByEventId(Event).Count();
            return(userlist);
        }
Exemplo n.º 24
0
        public ActionResult UserEdit(RegisteredUserModel model)
        {
            if (Session["CustomerId"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            RegisteredUser registeredUser = RegisteredUserService.GetRegisteredUserById(model.UserId);

            registeredUser.EventId            = model.EventId;
            registeredUser.FirstName          = model.FirstName;
            registeredUser.LastName           = model.LastName;
            registeredUser.Email              = model.Email;
            registeredUser.Country            = model.Country;
            registeredUser.DateOfRegistration = model.DateOfRegistration;
            registeredUser.IsDeleted          = model.IsDeleted;
            registeredUser.IsRegistered       = model.IsRegistered;
            registeredUser.ProfileImage       = model.ProfileImage;
            registeredUser.ProfileLink        = model.ProfileLink;
            RegisteredUserService.UpdateRegisteredUser(registeredUser);

            ViewBag.StatusMessage = "SuccessUpdate";
            return(View(model));
        }
Exemplo n.º 25
0
 public ActionResult Join(JoinEntry joinEntry)
 {
     try
     {
         int entryId;
         using (var context = new EntryContext())
         {
             var entryLogicService = new EntryService();
             entryId = entryLogicService.GetByEntryNumber(int.Parse(joinEntry.EntryNumber)).Id;
         }
         using (var context = new RegisteredUserContext())
         {
             var regUserService = new RegisteredUserService(context);
             regUserService.JoinEntry(int.Parse(User.Identity.Name), entryId);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw new Exception("EF broke... Ask robin");
     }
     return(View());
 }
Exemplo n.º 26
0
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha, string Domain, int Event, int ReferralId)
        {
            Domain      = Domain.Trim().ToLower();
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            //int CustomerId = Convert.ToInt32(Session["CustomerId"]);
            int CustomerId = 0;

            ViewBag.CustomerId = CustomerId;
            List <RegisteredUserModel> userlist = new List <RegisteredUserModel>();
            var regusers = RegisteredUserService.SearchRegisteredUser(SearchTitle, Alpha, Domain, Event, ReferralId);

            foreach (var user in regusers)
            {
                RegisteredUserModel registeredUserModel = new RegisteredUserModel();
                registeredUserModel.UserId             = user.UserId;
                registeredUserModel.FirstName          = user.FirstName;
                registeredUserModel.LastName           = user.LastName;
                registeredUserModel.Email              = user.Email;
                registeredUserModel.Country            = user.Country;
                registeredUserModel.DomainName         = user.DomainName;
                registeredUserModel.EventId            = user.EventId;
                registeredUserModel.EventName          = user.EventName;
                registeredUserModel.EventStartDate     = user.EventStartDate;
                registeredUserModel.EventEndDate       = user.EventEndDate;
                registeredUserModel.DateOfRegistration = user.DateOfRegistration;
                registeredUserModel.ReferralCount      = Convert.ToInt32(user.ReferralCount);
                registeredUserModel.ConnectionCount    = Convert.ToInt32(user.ConnectionCount);
                registeredUserModel.ProfileImage       = user.ProfileImage;
                registeredUserModel.CRM_CompanyName    = user.CRM_CompanyName;
                registeredUserModel.CRM_JobTitle       = user.CRM_JobTitle;
                registeredUserModel.Source             = user.Source;
                userlist.Add(registeredUserModel);
            }

            return(userlist);
        }
Exemplo n.º 27
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl, string loginType)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            ViewBag.loginType = loginType;
            var registeredUserService = new RegisteredUserService();
            var user = db.Users.Where(b => b.Email == model.Email).FirstOrDefault();

            //User does not exist.
            if (user == null)
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }

            if (!registeredUserService.IsEmailConfirmed(model.Email))
            {
                string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                ModelState.AddModelError("", model.Email + " is an unconfirmed email address. We have resent the confirmation email. Please check your email for your registration confirmation. If you have not received a confirmation please contact the Growing Connections administrator.");
                return(View(model));
            }

            if (!registeredUserService.IsValidUserNameForLoginType(model.Email, loginType))
            {
                ModelState.AddModelError("", model.Email + " is not a valid " + loginType + ".");
                return(View(model));
            }

            if (!registeredUserService.IsUserActive(model.Email, loginType))
            {
                ModelState.AddModelError("", model.Email + " is deactivated. Please contact the administrator.");
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(user.UserName, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                if (true)
                {
                    return(RedirectToAction("Index", "Listings"));
                }

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Exemplo n.º 28
0
        public ActionResult Grid(int IsBindData = 1, int currentPageIndex = 1, string orderby = "UserId", int IsAsc = 0, int PageSize = 10, int SearchRecords = 1, string Alpha = "", string SearchTitle = "", string Domain = "", int Event = 0, int ReferralId = 0)
        {
            try
            {
                if (IsArray == true)
                {
                    foreach (string a1 in Arr)
                    {
                        if (a1.Split(':')[0].ToString() == "IsBindData")
                        {
                            IsBindData = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "currentPageIndex")
                        {
                            currentPageIndex = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "orderby")
                        {
                            orderby = Convert.ToString(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "IsAsc")
                        {
                            IsAsc = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "PageSize")
                        {
                            PageSize = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "SearchRecords")
                        {
                            SearchRecords = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "Alpha")
                        {
                            Alpha = Convert.ToString(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "SearchTitle")
                        {
                            SearchTitle = Convert.ToString(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "Domain")
                        {
                            Domain = Convert.ToString(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "Event")
                        {
                            Event = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                        if (a1.Split(':')[0].ToString() == "ReferralId")
                        {
                            ReferralId = Convert.ToInt32(a1.Split(':')[1].ToString());
                        }
                    }
                }
            }
            catch { }

            IsArray = false;
            Arr     = new string[]
            { "IsBindData:" + IsBindData
              , "currentPageIndex:" + currentPageIndex
              , "orderby:" + orderby
              , "IsAsc:" + IsAsc
              , "PageSize:" + PageSize
              , "Alpha:" + Alpha
              , "SearchRecords:" + SearchRecords
              , "SearchTitle:" + SearchTitle
              , "Domain:" + Domain
              , "Event:" + Event
              , "ReferralId:" + ReferralId };

            int startIndex = ((currentPageIndex - 1) * PageSize) + 1;
            int endIndex   = startIndex + PageSize - 1;

            if (IsBindData == 1)
            {
                if (Event > 0)
                {
                    BindData = GetData(SearchRecords, SearchTitle, Alpha, Domain, Event, ReferralId).OfType <ReferralUserModel>().ToList();
                }
                else
                {
                    Event    = Convert.ToInt32(Request.QueryString["EventId"]);
                    BindData = GetData(SearchRecords, SearchTitle, Alpha, Domain, Event, ReferralId).OfType <ReferralUserModel>().ToList();
                }
                TotalDataCount = BindData.OfType <ReferralUserModel>().ToList().Count();
            }

            if (TotalDataCount == 0)
            {
                StatusMessage = "NoItem";
            }

            ViewBag.IsBindData       = IsBindData;
            ViewBag.CurrentPageIndex = currentPageIndex;
            ViewBag.LastPageIndex    = this.getLastPageIndex(PageSize);
            ViewBag.OrderByVal       = orderby;
            ViewBag.IsAscVal         = IsAsc;
            ViewBag.PageSize         = PageSize;
            ViewBag.SearchRecords    = SearchRecords;
            ViewBag.Alpha            = Alpha;
            ViewBag.SearchTitle      = SearchTitle;
            TempData["SearchTitle"]  = SearchTitle;
            ViewBag.StatusMessage    = StatusMessage;
            ViewBag.name             = name;
            ViewBag.pas               = pas;
            ViewBag.Domain            = Domain;
            ViewBag.Event             = Event;
            Session["eventid"]        = Event;
            TempData["eventid"]       = Event;
            ViewBag.ReferralId        = ReferralId;
            ViewBag.TotalRegistration = TotalDataCount;
            int         CustomerId = Convert.ToInt32(Session["CustomerId"]);
            var         ColumnName = typeof(ReferralUserModel).GetProperties().Where(p => p.Name == orderby).FirstOrDefault();
            IEnumerable Data       = null;

            ViewBag.TotalCount = RegisteredUserService.ReferralUsers(Event, CustomerId, SearchTitle).Count();
            if (IsAsc == 1)
            {
                ViewBag.AscVal = 0;
                Data           = BindData.OfType <ReferralUserModel>().ToList().OrderBy(n => ColumnName.GetValue(n, null)).Skip(startIndex - 1).Take(PageSize);
            }
            else
            {
                ViewBag.AscVal = 1;

                Data = BindData.OfType <ReferralUserModel>().ToList().OrderByDescending(n => ColumnName.GetValue(n, null)).Skip(startIndex - 1).Take(PageSize);
            }

            StatusMessage = "";
            Message       = "";
            //List<SelectListItem> domainlist = getdomain();
            //ViewBag.domainlist = domainlist;
            var eventid = Request.QueryString["EventId"];
            List <SelectListItem> eventlist = getevent(CustomerId, eventid);

            ViewBag.eventlist = eventlist;
            if (Event > 0)
            {
                ViewBag.Event = Event;
            }
            if (eventid != null)
            {
                ViewBag.Event = eventid;
            }
            return(View(Data));
        }
 public RegisteredUsersController(RegisteredUserService registeredUserService)
 {
     _registeredUserService = registeredUserService;
 }
Exemplo n.º 30
0
        //[HttpPost]
        public ActionResult GetRegisteredUserByUserId(int UserId)
        {
            try
            {
                var registeredUser = db.RegisteredUsers.Find(UserId);
                var eventid        = registeredUser.EventId;

                var eventtopost  = db.EventMasters.Find(eventid);
                var adminsetting = AdminService.GetAdminSetting();
                var utmsource    = adminsetting.Utm_Source;
                var utmmedium    = adminsetting.Utm_Medium;
                var utmcampaign  = adminsetting.Utm_Campaign;
                var utmcontent   = UserId;
                var utmterm      = eventid;
                eventtopost.Commentary = eventtopost.Commentary.Replace("\r\n", " ");
                var referralLink = "";
                if (eventtopost.DomainName.Contains("?"))
                {
                    referralLink = eventtopost.DomainName;// + "&r=" + UserId;
                    if (!eventtopost.DomainName.Contains("utm_source"))
                    {
                        referralLink = referralLink + "&utm_source=" + utmsource;
                    }
                    if (!eventtopost.DomainName.Contains("utm_medium"))
                    {
                        referralLink = referralLink + "&utm_medium=" + utmmedium;
                    }
                    if (!eventtopost.DomainName.Contains("utm_campaign"))
                    {
                        referralLink = referralLink + "&utm_campaign=" + utmcampaign;
                    }
                    if (!eventtopost.DomainName.Contains("utm_content"))
                    {
                        referralLink = referralLink + "&utm_content=" + utmcontent;
                    }
                    if (!eventtopost.DomainName.Contains("utm_term"))
                    {
                        referralLink = referralLink + "&utm_term=" + utmterm;
                    }
                    referralLink = referralLink + "&r=" + UserId;
                }
                else
                {
                    referralLink = eventtopost.DomainName + "?test=" + UserId;
                    if (!eventtopost.DomainName.Contains("utm_source"))
                    {
                        referralLink = referralLink + "&utm_source=" + utmsource;
                    }
                    if (!eventtopost.DomainName.Contains("utm_medium"))
                    {
                        referralLink = referralLink + "&utm_medium=" + utmmedium;
                    }
                    if (!eventtopost.DomainName.Contains("utm_campaign"))
                    {
                        referralLink = referralLink + "&utm_campaign=" + utmcampaign;
                    }
                    if (!eventtopost.DomainName.Contains("utm_content"))
                    {
                        referralLink = referralLink + "&utm_content=" + utmcontent;
                    }
                    if (!eventtopost.DomainName.Contains("utm_term"))
                    {
                        referralLink = referralLink + "&utm_term=" + utmterm;
                    }
                    referralLink = referralLink + "&r=" + UserId;
                }

                referralLink = System.Web.HttpUtility.UrlEncode(referralLink);
                var register_userlist = new RegisteredUserModel();

                var           client   = new RestClient("https://api-ssl.bitly.com/v3/shorten?access_token=96cc216b40bdbce6e032fcaeb2505ff997986706&longUrl=" + referralLink);
                var           request  = new RestRequest(Method.GET);
                IRestResponse response = client.Execute(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    dynamic tmp = JsonConvert.DeserializeObject(response.Content);
                    referralLink = (string)tmp.data.url;
                }

                List <UserMasterModel> userlist = new List <UserMasterModel>();
                var regusers = RegisteredUserService.Eventwiseuser("", "", "", (int)eventid, eventtopost.CustomerId, 0).ToList().Where(x => x.UserId != UserId);
                foreach (var user in regusers)
                {
                    UserMasterModel model = new UserMasterModel();
                    model.UserId             = user.UserId;
                    model.FullName           = user.FirstName + " " + user.LastName;
                    model.ReferredBy         = user.ReferredBy;
                    model.Email              = user.Email;
                    model.Country            = user.Country;
                    model.DomainName         = user.DomainName;
                    model.EventId            = user.EventId;
                    model.EventName          = user.EventName;
                    model.EventStartDate     = user.EventStartDate;
                    model.EventEndDate       = user.EventEndDate;
                    model.DateOfRegistration = user.DateOfRegistration;
                    model.ReferralCount      = Convert.ToInt32(user.ReferralCount);
                    model.ConnectionCount    = Convert.ToInt32(user.ConnectionCount);
                    model.ProfileImage       = user.ProfileImage;
                    model.visitorcount       = user.VisitorCount;
                    model.CRM_CompanyName    = user.CRM_CompanyName != null ? user.CRM_CompanyName : "";
                    model.CRM_JobTitle       = user.CRM_JobTitle != null ? user.CRM_JobTitle : "";
                    model.CRM_RegistrationId = user.CRM_RegistrationId;
                    model.Source             = user.Source;
                    userlist.Add(model);
                }
                return(Json(new { RegisteredUser = userlist, success = true, ReferralLink = referralLink }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = "Could not saved Data"
                }));
            }
        }