Esempio n. 1
0
    public void btnAddMediaRole_Clicked(object sender, EventArgs e)
    {
        if(dlRolesToAssign.Items.Count == 0)
            throw new Exception("Roles must be created first before trying to assign roles.");
        MonkData db = new MonkData();
        Monks.jkp_MediaRole mediaRole = new Monks.jkp_MediaRole();
        if(MediaType == Monks.Enums.MediaTypes.Audio)
            mediaRole.AudioId = ItemId;
        else if(MediaType == Monks.Enums.MediaTypes.Book)
            mediaRole.BookId = ItemId;
        else if(MediaType == Monks.Enums.MediaTypes.Image)
            mediaRole.ImageId = ItemId;
        else if(MediaType == Monks.Enums.MediaTypes.Video)
            mediaRole.VideoId = ItemId;
        mediaRole.RoleId = new Guid(dlRolesToAssign.SelectedValue);
        mediaRole.MediaRoleId = Guid.NewGuid();

        var existingSameRole = from d in db.jkp_MediaRoles
                               where object.Equals( d.AudioId, mediaRole.AudioId) && object.Equals( d.BookId, mediaRole.BookId) && object.Equals( d.ImageId, mediaRole.ImageId) && object.Equals(d.VideoId , mediaRole.VideoId)
                               && d.RoleId == mediaRole.RoleId
                               select d;
        if(existingSameRole.Count() > 0)
        {
            modalAddRole.Hide();
            return;
        }

        db.jkp_MediaRoles.InsertOnSubmit(mediaRole);
        db.SubmitChanges();
        LoadPageData();
        modalAddRole.Hide();
    }
Esempio n. 2
0
		private void detach_jkp_MediaRoles(jkp_MediaRole entity)
		{
			this.SendPropertyChanging();
			entity.jkp_Book = null;
		}
Esempio n. 3
0
		private void attach_jkp_MediaRoles(jkp_MediaRole entity)
		{
			this.SendPropertyChanging();
			entity.jkp_Audio = this;
		}
Esempio n. 4
0
		private void attach_jkp_MediaRoles(jkp_MediaRole entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_Role = this;
		}