Ejemplo n.º 1
0
        public string SetServiceAsBuddyIcon(string service)
        {
            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
            var id = memberShipHelper.GetCurrentMemberId();

            return(SetAvatar(id, service));
        }
        /// <summary>
        /// Deletes a member and all their associated data
        /// @Html.ActionLink("Delete Profile", "HandleDeleteProfile", "MemberEdit")
        /// </summary>
        /// <returns></returns>
        public ActionResult HandleDeleteProfile()
        {
            try
            {
                // Get the current member
                var membershipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
                var member           = Services.MemberService.GetById(membershipHelper.GetCurrentMemberId());

                //TODO-OPTIONAL:    Notify the member that their profile is being deleted in x days, giving them a couple of days to cancel this.
                //                  -> Then delete the member with a scheduled task automatically after that period of time.

                // Delete the member
                Services.MemberService.Delete(member);
            }
            catch (Exception ex)
            {
                //TODO-1: Log the exception
                throw;
            }

            // Log the member out
            FormsAuthentication.SignOut();

            // Redirect home or to a custom page
            return(Redirect("/"));
        }
Ejemplo n.º 3
0
        public void UpdateDownloadCount(int fileId, bool ignoreCookies, bool isPackage)
        {
            var cookie = HttpContext.Current.Request.Cookies["ProjectFileDownload" + fileId];

            if (cookie != null && ignoreCookies == false)
            {
                return;
            }

            var downloads = 0;
            var projectId = 0;

            var reader = Application.SqlHelper.ExecuteReader("Select downloads, nodeId from wikiFiles where id = @id;", Application.SqlHelper.CreateParameter("@id", fileId));

            if (reader.Read())
            {
                downloads = reader.GetInt("downloads");
                projectId = reader.GetInt("nodeId");
            }
            downloads = downloads + 1;

            Application.SqlHelper.ExecuteNonQuery(
                "update wikiFiles set downloads = @downloads where id = @id;",
                Application.SqlHelper.CreateParameter("@id", fileId),
                Application.SqlHelper.CreateParameter("@downloads", downloads));

            var totalDownloads = Application.SqlHelper.ExecuteScalar <int>("Select SUM(downloads) from wikiFiles where nodeId = @projectId;", Application.SqlHelper.CreateParameter("@projectId", projectId));

            if (isPackage)
            {
                var memberHelper    = new Umbraco.Web.Security.MembershipHelper(Umbraco.Web.UmbracoContext.Current);
                var memberId        = memberHelper.GetCurrentMemberId();
                var currentMemberId = memberId == -1 ? 0 : memberId;

                //update download count update
                Application.SqlHelper.ExecuteNonQuery(
                    @"insert into projectDownload(projectId,memberId,timestamp) 
                        values((select nodeId from wikiFiles where id = @id) ,@memberId, getdate())",
                    Application.SqlHelper.CreateParameter("@id", fileId),
                    Application.SqlHelper.CreateParameter("@memberId", currentMemberId));
            }

            var e = new FileDownloadUpdateEventArgs {
                ProjectId = projectId, Downloads = totalDownloads
            };

            FireAfterDownloadUpdate(e);

            cookie = new HttpCookie("ProjectFileDownload" + fileId)
            {
                Expires = DateTime.Now.AddHours(1)
            };
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
Ejemplo n.º 4
0
        //api/topic
        public void Delete(int id)
        {
            var c = TopicService.GetById(id);

            if (c == null)
            {
                throw new Exception("Topic not found");
            }


            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext);
            var currentMemberId  = memberShipHelper.GetCurrentMemberId();

            if (Library.Utils.IsModerator() == false && c.MemberId != currentMemberId)
            {
                throw new Exception("You cannot delete this topic");
            }

            TopicService.Delete(c);
        }
Ejemplo n.º 5
0
        public MyPageViewModel()
        {
            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
            var memberId         = memberShipHelper.GetCurrentMemberId();
            var memberService    = ApplicationContext.Current.Services.MemberService;
            var m = memberService.GetById(memberId);

            Id    = m.Id;
            Name  = m.Name;
            Email = m.Email;
            Login = m.Name;

            var memberRoles = System.Web.Security.Roles.GetRolesForUser(m.Username);

            MemberGroup = string.Join(",", memberRoles.Select(item => item));

            MemberType = m.ContentType.Name;
            //FirstName = m.GetValue<string>("firstname");
            //LastName = m.GetValue<string>("lastname");
            //Address = m.GetValue<string>("Address");
            //ContactPerson = m.GetValue<string>("ContactPerson");
        }
        /// <summary>
        /// Update the logged in members password
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult HandleChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("ChangePassword", model));
            }

            var membershipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);

            // Get the current member
            var member = Services.MemberService.GetById(membershipHelper.GetCurrentMemberId());

            //TODO-1: Validate their current password

            //Save the password for the member
            Services.MemberService.SavePassword(member, model.Password);

            //TODO-2: Notify the member that their password was just changed

            //Return the view
            return(PartialView("ChangePassword", model));
        }
Ejemplo n.º 7
0
        public string ChangeCollabStatus(int projectId, bool status)
        {
            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
            var currentMember    = memberShipHelper.GetCurrentMemberId();

            if (currentMember <= 0)
            {
                return("false");
            }

            var contentService = ApplicationContext.Services.ContentService;
            var content        = contentService.GetById(projectId);

            if (content.GetValue <int>("owner") != currentMember)
            {
                return("false");
            }

            content.SetValue("openForCollab", status);
            var result = contentService.PublishWithStatus(content);

            return(result.Success.ToString());
        }
Ejemplo n.º 8
0
        public string RemoveContributor(int projectId, int memberId)
        {
            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
            var currentMember    = memberShipHelper.GetCurrentMemberId();

            if (currentMember <= 0)
            {
                return("false");
            }

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var content       = umbracoHelper.Content(projectId);

            if (content.GetPropertyValue <int>("owner") != currentMember)
            {
                return("false");
            }

            var projectContributor = new ProjectContributor(projectId, memberId);

            projectContributor.Delete();

            return("true");
        }
Ejemplo n.º 9
0
        public void UpdateDownloadCount(int fileId, bool ignoreCookies, bool isPackage)
        {
            var cookie = HttpContext.Current.Request.Cookies["ProjectFileDownload" + fileId];

            if (cookie != null && ignoreCookies == false)
                return;

            var downloads = 0;
            var projectId = 0;

            var reader = Application.SqlHelper.ExecuteReader("Select downloads, nodeId from wikiFiles where id = @id;", Application.SqlHelper.CreateParameter("@id", fileId));
            if (reader.Read())
            {
                downloads = reader.GetInt("downloads");
                projectId = reader.GetInt("nodeId");
            }
            downloads = downloads + 1;

            Application.SqlHelper.ExecuteNonQuery(
                "update wikiFiles set downloads = @downloads where id = @id;",
                Application.SqlHelper.CreateParameter("@id", fileId),
                Application.SqlHelper.CreateParameter("@downloads", downloads));

            var totalDownloads = Application.SqlHelper.ExecuteScalar<int>("Select SUM(downloads) from wikiFiles where nodeId = @projectId;", Application.SqlHelper.CreateParameter("@projectId", projectId));

            if (isPackage)
            {
                var memberHelper = new Umbraco.Web.Security.MembershipHelper(Umbraco.Web.UmbracoContext.Current);
                var memberId = memberHelper.GetCurrentMemberId();
                var currentMemberId = memberId == -1 ? 0 : memberId;

                //update download count update
                Application.SqlHelper.ExecuteNonQuery(
                    @"insert into projectDownload(projectId,memberId,timestamp)
                        values((select nodeId from wikiFiles where id = @id) ,@memberId, getdate())",
                    Application.SqlHelper.CreateParameter("@id", fileId),
                    Application.SqlHelper.CreateParameter("@memberId", currentMemberId));
            }

            var e = new FileDownloadUpdateEventArgs { ProjectId = projectId, Downloads = totalDownloads };
            FireAfterDownloadUpdate(e);

            cookie = new HttpCookie("ProjectFileDownload" + fileId) { Expires = DateTime.Now.AddHours(1) };
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
Ejemplo n.º 10
0
        public ExistingComplaintReportViewModel(ComplaintReport c)
        {
            ComplaintReportId = c.ComplaintReportId;
            MachineNo1        = c.MachineNo1;
            MachineNo2        = c.MachineNo2;
            DealerId          = c.MemberId;
            SaleDate          = c.SaleDate;
            DamageDate        = c.DamageDate;
            RepairDate        = c.RepairDate;
            TimeAmount        = c.TimeAmount;
            EngineNo          = c.EngineNo;
            Customer          = new CustomerViewModel()
            {
                CustomerId   = c.Customer.CustomerId,
                Name         = c.Customer.Name,
                Address      = c.Customer.Address,
                CustomerType = c.Customer.CustomerType
            };

            var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(Umbraco.Web.UmbracoContext.Current);
            var memberId         = memberShipHelper.GetCurrentMemberId();
            var memberService    = ApplicationContext.Current.Services.MemberService;
            var m = memberService.GetById(c.MemberId);

            Dealer = new DealerViewModel(m);

            Product      = new ProductViewModel(c.ProductModel.Product);
            ProductModel = new ProductModelViewModel(c.ProductModel);
            Status       = c.Status;

            SelectedProduct      = c.ProductModel.ProductId;
            SelectedProductModel = c.ProductModelId;

            Closed         = c.Closed;
            Error          = c.Error;
            ReasonForError = c.ReasonForError;
            PartsMarked    = c.PartsMarked;
            PartsReturned  = c.PartsReturned;
            CreateEmail    = c.CreateEmail;

            //Parts = new List<PartViewModel>();


            //Parts.AddRange(c.ComplaintReportParts.Select(p =>
            //    new PartViewModel(){
            //        PartId = p.PartId,
            //        Description = p.Description,
            //        PartNo = p.PartNo,
            //        Price = p.Price,
            //        Shipping = p.Shipping,
            //    }));

            var parts = c.ComplaintReportParts.Select(p =>
                                                      new PartViewModel()
            {
                PartId      = p.PartId,
                Description = p.Part.Description,
                PartNo      = p.Part.PartNo,
                Price       = p.Part.Price,
                Shipping    = p.Part.Shipping,
                Amount      = p.Amount
            });

            Parts = new List <PartViewModel>();
            Parts.AddRange(parts);
            SentToApproval = c.SentToApproval;
        }