public BorrowInfo UpdateBorrowInfo(BorrowInfo _borrow) { try { using (var context = new LibrarySystemEntities()) { BorrowInfo oldborrow = context.BorrowInfoes.FirstOrDefault(c => c.BorrowId == _borrow.BorrowId); if (oldborrow != null) { oldborrow.BorrowDate = _borrow.BorrowDate; oldborrow.ReturnDate = _borrow.ReturnDate; oldborrow.ReaderId = _borrow.ReaderId; oldborrow.IsActive = _borrow.IsActive; context.SaveChanges(); return oldborrow; } return null; } } catch (Exception) { throw; } }
public MethodResponse UpdateBorrowInfoForWCF(BorrowInfo _borrow) { MethodResponse methodresponse = new MethodResponse(); try { BorrowInfo borrow = UpdateBorrowInfo(_borrow); methodresponse.Type = MethodResponse.ResponseType.Succeed; methodresponse.ResultText = "Borrow Info Updated"; methodresponse.Object = borrow; } catch (Exception ex) { CustomException custom_exception = new CustomException() { Exception = ex, ExceptionTime = DateTime.Now, Parameters = "", HelpLink = "", User = "", MethodName = "UpdateBorrowInfoForWCF" }; 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 Borrow Info"; } return methodresponse; }
public BorrowInfo AddBorrowInfo(BorrowInfo _borrow) { try { using (var context = new LibrarySystemEntities()) { context.Configuration.ProxyCreationEnabled = false; context.BorrowInfoes.Add(_borrow); context.SaveChanges(); return _borrow; } } catch (Exception) { throw; } }