public void ajaxSongRating_Changed(object sender, AjaxControlToolkit.RatingEventArgs e) { ResetPanels(); var setSongId = new Guid(e.Tag); var userId = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString()); var rating = (int?)int.Parse(e.Value); var analysisService = new AnalysisService(Ioc.GetInstance <IAnalysisRepository>()); var analysis = analysisService.GetAnalysisBySetSongAndUser(setSongId, userId).SingleOrDefault(); if (analysis != null) { using (IUnitOfWork uow = UnitOfWork.Begin()) { analysis.Rating = rating; uow.Commit(); } } else { Guid?myShowId = null; if (!string.IsNullOrEmpty(hdnMyShowId.Value)) { myShowId = new Guid(hdnMyShowId.Value); } Analysis newAnalysis = new Analysis { AnalysisId = Guid.NewGuid(), CreatedDate = DateTime.Now, MyShowId = myShowId, Rating = rating, SetSongId = setSongId, UserId = userId }; bool success = false; analysisService.SaveCommit(newAnalysis, out success); } }