public Publisher UpdatePublisher(Publisher _publisher) { try { using (var context = new LibrarySystemEntities()) { Publisher oldpublisher = context.Publisher.FirstOrDefault(c => c.PublisherId == _publisher.PublisherId); if (oldpublisher != null) { oldpublisher.PublisherName = _publisher.PublisherName; oldpublisher.PublisherId = _publisher.PublisherId; oldpublisher.IsActive = _publisher.IsActive; context.SaveChanges(); return oldpublisher; } return null; } } catch (Exception) { throw; } }
public MethodResponse UpdatePublisherForWCF(Publisher _publisher) { MethodResponse methodresponse = new MethodResponse(); try { Publisher publisher = UpdatePublisher(_publisher); methodresponse.Type = MethodResponse.ResponseType.Succeed; methodresponse.ResultText = "Publisher Updated"; methodresponse.Object = publisher; } catch (Exception ex) { CustomException custom_exception = new CustomException() { Exception = ex, ExceptionTime = DateTime.Now, Parameters = "", HelpLink = "", User = "", MethodName = "UpdatePublisherForWCF" }; CustomExceptionDB custom_exceptionDB = new CustomExceptionDB(); bool isSaved = custom_exceptionDB.SaveException(custom_exception); if (isSaved == true) { //.. } methodresponse.Object = null; methodresponse.Type = MethodResponse.ResponseType.Error; methodresponse.ResultText = "An Error Occurred While Updating Publisher "; } return methodresponse; }
public Publisher AddPublisher(Publisher _publisher) { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; context.Publisher.Add(_publisher); context.SaveChanges(); return _publisher; } } catch (Exception) { throw; } }