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(); }
private void detach_jkp_MediaRoles(jkp_MediaRole entity) { this.SendPropertyChanging(); entity.jkp_Book = null; }
private void attach_jkp_MediaRoles(jkp_MediaRole entity) { this.SendPropertyChanging(); entity.jkp_Audio = this; }
private void attach_jkp_MediaRoles(jkp_MediaRole entity) { this.SendPropertyChanging(); entity.aspnet_Role = this; }