public bool AddTeacher(IConnectionHandler handler, Guid workShopId, Guid teacherId) { var workShopTeacherBO = new WorkShopTeacherBO(); var shopTeacher = workShopTeacherBO.Get(handler, workShopId, teacherId); if (shopTeacher != null) { return(true); } var workShopTeacher = new WorkShopTeacher { TeacherId = teacherId, WorkShopId = workShopId }; if (!workShopTeacherBO.Insert(handler, workShopTeacher)) { throw new Exception(Resources.Congress.ErrorInSaveWorkShopTeacher); } return(true); }
public bool Insert(WorkShop workShop, List <Guid> teacherList, HttpPostedFileBase fileProgram, HttpPostedFileBase file) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.CommonConnection.StartTransaction(IsolationLevel.ReadUncommitted); var id = workShop.Id; BOUtility.GetGuidForId(ref id); workShop.Id = id; var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection); if (fileProgram != null) { workShop.ProgramAttachId = fileTransactionalFacade.Insert(fileProgram); } if (file != null) { workShop.FileAttachId = fileTransactionalFacade.Insert(file); } if (!new WorkShopBO().Insert(this.ConnectionHandler, workShop)) { throw new Exception(Resources.Congress.ErrorInSaveWorkShop); } if (teacherList.Count > 0) { foreach (var guid in teacherList) { var workShopTeacher = new WorkShopTeacher { TeacherId = guid, WorkShopId = workShop.Id }; if (!new WorkShopTeacherBO().Insert(this.ConnectionHandler, workShopTeacher)) { throw new Exception(Resources.Congress.ErrorInSaveWorkShopTeacher); } } } this.ConnectionHandler.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); this.CommonConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); this.CommonConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); this.CommonConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }