public void Update(ConferenceDeclaration item) { using (APCRSHREntities context = new APCRSHREntities()) { var result = context.ConferenceDeclarations.Where(n => n.ConferenceID.Equals(item.ConferenceID)).SingleOrDefault(); if (result != null) { result.Title = item.Title; if (!string.IsNullOrEmpty(item.ActionURL)) { result.ActionURL = item.ActionURL; } if (!string.IsNullOrEmpty(item.AttachmentURL)) { result.AttachmentURL = item.AttachmentURL; } if (!string.IsNullOrEmpty(item.ImageURL)) { result.ImageURL = item.ImageURL; } result.Contents = item.Contents; result.ShortContent = item.ShortContent; result.UpdatedBy = item.UpdatedBy; result.UpdatedDate = DateTime.Now; context.SaveChanges(); } else { throw new Exception(string.Format("Conference's id {0} invalid", item.ConferenceID)); } } }
public object Insert(ConferenceDeclaration item) { using (APCRSHREntities context = new APCRSHREntities()) { context.ConferenceDeclarations.Add(item); context.SaveChanges(); return(item.ConferenceID); } }
public FindItemReponse <ConferenceDeclarationModel> FindConferenceByActionURL(string actionURL) { try { IConferenceDeclarationRepository conRepository = RepositoryClassFactory.GetInstance().GetConferenceDeclarationRepository(); ConferenceDeclaration con = conRepository.FindByActionURL(actionURL); var _con = MapperUtil.CreateMapper().Mapper.Map <ConferenceDeclaration, ConferenceDeclarationModel>(con); return(new FindItemReponse <ConferenceDeclarationModel> { Item = _con, ErrorCode = (int)ErrorCode.None, Message = string.Empty }); } catch (Exception ex) { return(new FindItemReponse <ConferenceDeclarationModel> { ErrorCode = (int)ErrorCode.Error, Message = ex.Message }); } }
public InsertResponse CreateConference(ConferenceDeclarationModel conference) { try { IConferenceDeclarationRepository conferenceRepository = RepositoryClassFactory.GetInstance().GetConferenceDeclarationRepository(); ConferenceDeclaration _con = MapperUtil.CreateMapper().Mapper.Map <ConferenceDeclarationModel, ConferenceDeclaration>(conference); object id = conferenceRepository.Insert(_con); return(new InsertResponse { InsertID = id.ToString(), ErrorCode = (int)ErrorCode.None, Message = Resources.Resource.msg_create_success }); } catch (Exception ex) { return(new InsertResponse { ErrorCode = (int)ErrorCode.Error, Message = ex.Message }); } }