示例#1
0
        /// <summary>
        /// Creates a user to the database with IsApproved = false.
        /// </summary>
        /// <param name="contentLocator">Whether TestContentLocator or WebContentLocator</param>
        /// <returns></returns>
        public MembershipCreateStatus CreateUser(IContentLocator contentLocator)
        {
            if (String.IsNullOrEmpty(this.User.Email))
            {
                return(MembershipCreateStatus.InvalidEmail);
            }

            MembershipCreateStatus createStatus;

            MembershipUser newUser = Membership.CreateUser(
                this.User.UserName,
                this.User.Password,
                this.User.Email,
                "dummy question",
                "dummy answer",
                false,
                out createStatus);

            if (createStatus == MembershipCreateStatus.Success)
            {
                try
                {
                    Roles.AddUserToRole(this.User.UserName, "User");
                    CreateUserDetails();
                    SendVerificationEmail(newUser.ProviderUserKey.ToString(), contentLocator);
                }
                catch (Exception)
                {
                    return(MembershipCreateStatus.UserRejected);
                }
            }
            return(createStatus);
        }
示例#2
0
        /// <summary>
        /// Creates a user to the database with IsApproved = false.
        /// </summary>
        /// <param name="contentLocator">Whether TestContentLocator or WebContentLocator</param>
        /// <returns></returns>
        public MembershipCreateStatus CreateUser(IContentLocator contentLocator)
        {
            if (String.IsNullOrEmpty(this.User.Email))
            {
                return MembershipCreateStatus.InvalidEmail;
            }

            MembershipCreateStatus createStatus;

            MembershipUser newUser = Membership.CreateUser(
                this.User.UserName, 
                this.User.Password,
                this.User.Email, 
                "dummy question",
                "dummy answer", 
                false, 
                out createStatus);

            if (createStatus == MembershipCreateStatus.Success)
            {
                try
                {
                    Roles.AddUserToRole(this.User.UserName, "User");
                    CreateUserDetails();
                    SendVerificationEmail(newUser.ProviderUserKey.ToString(), contentLocator);
                }
                catch (Exception)
                {                    
                    return MembershipCreateStatus.UserRejected;
                }
            }
            return createStatus;
        }
示例#3
0
        /// <summary>
        /// Saves the video to the file system.
        /// </summary>
        public void Save(IContentLocator contentLocator)
        {
            if (!this.IsValidFile)
            {
                throw new Exception("Invalid file type. Can only accept mp4, avi, ogv and webm extensions.");
            }

            String filePath = contentLocator.GetPath(this.Url);
            this.File.SaveAs(filePath);
        }
示例#4
0
        /// <summary>
        /// Saves the Audio to the file system
        /// </summary>
        public void Save(IContentLocator contentLocator)
        {
            if (!this.IsValidFile)
            {
                throw new Exception("Invalid file type. Can only accept mp3 and wav extensions.");
            }

            String filePath = contentLocator.GetPath(this.Url);

            this.File.SaveAs(filePath);
        }
示例#5
0
        /// <summary>
        /// Sends an email to the user with verification link.
        /// </summary>
        private void SendVerificationEmail(String userId, IContentLocator contentLocator)
        {
            String filePath = contentLocator.GetPath("~/Content/documents/VerifyAccount.html");

            string emailContent =
                File.ReadAllText(filePath)
                    .Replace("%FirstName%", this.User.FirstName)
                    .Replace("%UserId%", userId);

            Email email = new Email
            {
                FromEmail = "*****@*****.**",
                FromName = "Crime Buster Admin",
                ToEmail = this.User.Email,
                Subject = "[Crime Busters] Please Verify Your Account",
                Body = emailContent,
                IsHighImportance = true
            };
            email.SendEmail();
        }
        /// <summary>
        /// Creates a report that will be saved to the database.
        /// </summary>
        /// <returns>success for successful insert, else will return the error message.</returns>
        public string CreateReport(IContentLocator contentLocator)
        {
            foreach (var document in Media.Where(document => document != null))
            {
                AddUrlList(document.Url);
                document.Save(contentLocator);
            }

            try
            {
                ReportsDAO.CreateReport(ReportTypeId, Message,
                                        Latitude, Longitude, Location, DateReported,
                                        User.UserName, UrlList);
                return("success");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
示例#7
0
        /// <summary>
        /// Sends an email to the user with verification link.
        /// </summary>
        private void SendVerificationEmail(String userId, IContentLocator contentLocator)
        {
            String filePath = contentLocator.GetPath("~/Content/documents/VerifyAccount.html");

            string emailContent =
                File.ReadAllText(filePath)
                .Replace("%FirstName%", this.User.FirstName)
                .Replace("%UserId%", userId);

            Email email = new Email
            {
                FromEmail        = "*****@*****.**",
                FromName         = "Crime Buster Admin",
                ToEmail          = this.User.Email,
                Subject          = "[Crime Busters] Please Verify Your Account",
                Body             = emailContent,
                IsHighImportance = true
            };

            email.SendEmail();
        }
 public ContentLocatorCachingProxy(IContentLocator contentLocator)
 {
     _contentLocator = contentLocator;
 }
        /// <summary>
        /// Creates a report that will be saved to the database.
        /// </summary>
        /// <returns>success for successful insert, else will return the error message.</returns>
        public string CreateReport(IContentLocator contentLocator) 
        {
            foreach (var document in Media.Where(document => document != null))
            {
                AddUrlList(document.Url);
                document.Save(contentLocator);
            }

            try
            {
                ReportsDAO.CreateReport(ReportTypeId, Message, 
                    Latitude, Longitude, Location, DateReported, 
                    User.UserName, UrlList);
                return "success";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
 public EventListingPageController(IContentLocator contentLocator)
 {
     _contentLocator = contentLocator;
 }
 public RootContentLocatorCachingProxy(IRootContentLocator rootContentLocator, IContentLocator contentLocator)
 {
     _rootContentLocator = rootContentLocator;
     _contentLocator = contentLocator;
 }
 public ContentLocatorCachingProxy(IContentLocator contentLocator)
 {
     _contentLocator = contentLocator;
 }
 public RootContentLocatorCachingProxy(IRootContentLocator rootContentLocator, IContentLocator contentLocator)
 {
     _rootContentLocator = rootContentLocator;
     _contentLocator     = contentLocator;
 }