private void BindData()
        {
            PersonBiz  pBiz   = new PersonBiz();
            lwg_Person person = pBiz.GetByID(this.ComposerId);

            if (person != null)
            {
                txtDOB.Text          = person.DOB;
                txtDOD.Text          = person.DOD;
                txtFirstName.Text    = (String)person.FirstName;
                txtLastName.Text     = (String)person.LastName;
                txtNameDisplay.Text  = (String)person.NameDisplay;
                txtNameList.Text     = (String)person.NameList;
                txtNameSort.Text     = (String)person.NameSort;
                txtBiography.Content = Server.HtmlDecode(person.Biography);

                if (person.PictureID.HasValue)
                {
                    if (person.PictureID.Value > 0)
                    {
                        Picture Picture = PictureManager.GetPictureById(person.PictureID.Value);
                        this.btnRemoveImage.Visible = Picture != null;
                        string pictureUrl = PictureManager.GetPictureUrl(Picture, 100);
                        this.iPicture.Visible  = true;
                        this.iPicture.ImageUrl = pictureUrl;
                    }
                }
            }
        }
Beispiel #2
0
        public List <lwg_Person> GetTopComposer(int number)
        {
            if (number > 0)
            {
                List <lwg_Person> lstResult = new List <lwg_Person>();
                var query = from temp in dbContext.lwg_PersonInRole
                            where temp.RoleId == LWGUtils.COMPOSER_ROLE_ID
                            group temp by temp.PersonId into g
                            orderby g.Count() descending
                            select g.Key;

                int j             = 0;
                var lwg_PersonTmp = dbContext.lwg_Person.ToList();
                foreach (int i in query)
                {
                    if (j < number)
                    {
                        lwg_Person lwg = lwg_PersonTmp.SingleOrDefault(lg => lg.PersonId == i);
                        if (lwg != null)
                        {
                            lstResult.Insert(lstResult.Count, lwg);
                        }
                        j++;
                    }
                    else
                    {
                        break;
                    }
                }
                return(lstResult);
            }
            return(null);
        }
Beispiel #3
0
        public bool DeletePerson(long PersonId)
        {
            lwg_Person person = GetByID(PersonId);

            if (person != null)
            {
                dbContext.lwg_Person.Remove(person);
                dbContext.SaveChanges();
                return(true);
            }
            return(false);
        }
Beispiel #4
0
 public lwg_Person SaveImport(lwg_Person p)
 {
     if (dbContext.lwg_Person.Count() > 0)
     {
         p.PersonId = dbContext.lwg_Person.Max(ct => ct.PersonId) + 1;
     }
     else
     {
         p.PersonId = 1;
     }
     dbContext.lwg_Person.Add(p);
     dbContext.SaveChanges();
     return(p);
 }
        protected void btnRemoveImage_Click(object sender, EventArgs e)
        {
            lwg_Person person = null;
            PersonBiz  pbiz   = new PersonBiz();

            person = pbiz.GetByID(this.ComposerId);
            if (person != null)
            {
                PictureManager.DeletePicture(person.PictureID.Value);
                person.PictureID = 0;
                pbiz.SavePerson(person);
                btnRemoveImage.Visible = false;
                BindData();
            }
        }
Beispiel #6
0
 public bool SavePerson(lwg_Person h)
 {
     if (h != null)
     {
         if (h.PersonId > 0)
         {
             lwg_Person c = dbContext.lwg_Person.SingleOrDefault(ht => ht.PersonId == h.PersonId);
             if (c != null)
             {
                 c.Biography   = h.Biography;
                 c.DOB         = h.DOB;
                 c.DOD         = h.DOD;
                 c.FirstLetter = h.FirstLetter;
                 c.FirstName   = h.FirstName;
                 c.LastName    = h.LastName;
                 c.NameDisplay = h.NameDisplay;
                 c.NameList    = h.NameList;
                 c.NameSort    = h.NameSort;
                 c.PictureID   = h.PictureID;
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             if (dbContext.lwg_Person.Count() > 0)
             {
                 h.PersonId = dbContext.lwg_Person.Max(ct => ct.PersonId) + 1;
             }
             else
             {
                 h.PersonId = 1;
             }
             dbContext.lwg_Person.Add(h);
         }
         dbContext.SaveChanges();
         return(true);
     }
     return(false);
 }
        protected void dtlTopComposer_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                lwg_Person obj = (lwg_Person)e.Item.DataItem;
                if (obj != null)
                {
                    Label lblNumber = (Label)e.Item.FindControl("lblNumber");
                    lblNumber.Text = (e.Item.ItemIndex + 1).ToString();

                    HyperLink lblName = (HyperLink)e.Item.FindControl("lblName");
                    lblName.Text        = obj.NameDisplay;
                    lblName.NavigateUrl = string.Format("~/ComposerDetails.aspx?ComposerID={0}", obj.PersonId);

                    PersonBiz pBiz             = new PersonBiz();
                    Label     lblProductNumber = (Label)e.Item.FindControl("lblProductNumber");
                    lblProductNumber.Text = pBiz.CountTotalProductWithComposerRole(obj.PersonId).ToString();
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string title = GetLocaleResourceString("PageTitle.ComposerDetailsPage");

            SEOHelper.RenderTitle(this, title, true);
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["ComposerID"]))
                {
                    string PId = Request.QueryString["ComposerID"].ToString();

                    long PersonId = 0;

                    if (long.TryParse(PId, out PersonId))
                    {
                        try
                        {
                            PersonBiz  pb     = new PersonBiz();
                            lwg_Person person = pb.GetByID(PersonId);

                            if (person != null)
                            {
                                this.litName.Text = person.NameDisplay;
                                this.lblName.Text = person.NameDisplay;

                                this.Literal1.Text = "About " + person.NameDisplay;

                                if (!String.IsNullOrEmpty(person.Biography))
                                {
                                    this.Literal2.Text = Custring(person.Biography);
                                }

                                if (person.PictureID.HasValue)
                                {
                                    if (person.PictureID.Value > 0)
                                    {
                                        Picture Picture    = PictureManager.GetPictureById(person.PictureID.Value);
                                        string  pictureUrl = PictureManager.GetPictureUrl(Picture, 150);
                                        this.iPicture.Visible  = true;
                                        this.iPicture.ImageUrl = pictureUrl;
                                    }
                                }
                                else
                                {
                                    iPicture.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 150));
                                }
                            }
                            else
                            {
                                Response.Write("This composer doesn't exist.");
                            }
                        }
                        catch (Exception ex)
                        {
                            Response.Write(ex.Message);
                        }
                        return;
                    }
                }

                // Invalid Person ID. Go to Composers page or 404 page.
                Response.Redirect("~/MeetComposers.aspx");
            }
        }
        public string SaveInfo()
        {
            PersonBiz pBiz = new PersonBiz();

            lwg_Person person = pBiz.GetByID(this.ComposerId);

            Picture pic = null;

            if (person == null)
            {
                person = new lwg_Person();
            }
            else
            {
                if (person.PictureID.HasValue)
                {
                    if (person.PictureID.Value > 0)
                    {
                        pic = PictureManager.GetPictureById(person.PictureID.Value);
                    }
                }
            }

            HttpPostedFile PictureFile = fuPicture.PostedFile;

            if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName)))
            {
                byte[] pictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength);
                if (pic != null)
                {
                    pic = PictureManager.UpdatePicture(pic.PictureId, pictureBinary, PictureFile.ContentType, true);
                }
                else
                {
                    pic = PictureManager.InsertPicture(pictureBinary, PictureFile.ContentType, true);
                }
            }
            int PictureId = 0;

            if (pic != null)
            {
                PictureId = pic.PictureId;
            }

            person.Biography = Server.HtmlEncode(txtBiography.Content);

            if (txtDOB.Text.Trim() != person.DOB)
            {
                person.DOB = txtDOB.Text.Trim();
            }

            if (txtDOD.Text.Trim() != person.DOD)
            {
                person.DOD = txtDOD.Text.Trim();
            }
            string lastName = txtLastName.Text.Trim();

            person.FirstLetter = lastName.Length > 0 ? lastName.Substring(0, 1).ToUpper() : string.Empty;
            person.FirstName   = txtFirstName.Text.Trim();
            person.LastName    = lastName;
            person.NameDisplay = txtNameDisplay.Text.Trim();
            person.NameList    = txtNameList.Text.Trim();
            person.NameSort    = txtNameSort.Text.Trim();
            person.PictureID   = PictureId;

            pBiz.SavePerson(person);

            return(person.PersonId.ToString());
        }